/* ========================================
   UPD Constructor v12.0 Style Overrides
   FULL SPEC IMPLEMENTATION
   Extracted from inline styles for better performance
   ======================================== */

/* Стили для readonly поля суммы товара */
.product-total[readonly] {
  background-color: #f1f5f9 !important;
  color: #64748b !important;
  cursor: not-allowed !important;
}

/* Отключение transitions при массовом заполнении полей */
.no-transitions,
.no-transitions * {
  transition: none !important;
  animation: none !important;
}

/* Card Headers - единый стиль v12 для всех h4 в card-header */
.card-header h4,
.constructor-card-header-v12 h4,
.constructor-preview-header-v12 h4 {
  font-size: 18px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.3em !important;
  color: #94a3b8 !important;
  margin: 0 !important;
}

/* Page titles - h4 без класса, используемые как page title */
h4.mb-0,
h4.mb-24,
h4.mb-16 {
  font-size: 18px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.3em !important;
  color: #94a3b8 !important;
}

/* Центрирование контента для конструктора УПД */
.upd-constructor-page.dashboard-content-v12 {
  margin-left: auto !important;
  margin-right: auto !important;
  max-width: var(--docu-content-max-width) !important;
}

/* Documatica v12 Spacing System */
.docu-mb-48 {
  margin-bottom: 48px !important;
}

.docu-mb-32 {
  margin-bottom: 32px !important;
}

/* Page Background with Blue Dots Pattern - like homepage */
body.constructor-page-v12 {
  background-color: #f8fafc !important;
  background-image: radial-gradient(circle, #3b82f6 1px, transparent 1px) !important;
  background-size: 32px 32px !important;
  background-attachment: fixed !important;
}

/* Main Form Container - Cards with rounded corners */
.card.radius-16,
.card {
  background: white !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 2rem !important;
  overflow: hidden !important;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04) !important;
  margin-bottom: 24px !important;
}

/* Card Header - Technical Label Style */
.card-header {
  padding: 24px 32px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  background: transparent !important;
}


/* Card Body */
.card-body {
  padding: 32px !important;
}

/* Row and Grid fixes - moved to input-group section */
.row.g-8 {
  --bs-gutter-x: 8px !important;
}

.gap-28 {
  gap: 16px !important;
}

/* Form Labels - v12 Technical Style */
.form-label,
label.form-label {
  display: block !important;
  font-size: 9px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.15em !important;
  color: #94a3b8 !important;
  margin-left: 4px !important;
  margin-bottom: 8px !important;
  min-height: auto !important;
}

.form-label .text-danger,
.form-label span.text-danger {
  color: #ef4444 !important;
}

/* Form Inputs - v12 Spec */
.form-control,
input.form-control,
textarea.form-control {
  width: 100% !important;
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 1rem !important;
  padding: 14px 18px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
  transition: all 0.3s ease !important;
  height: auto !important;
}

.form-control::placeholder {
  font-size: 14px !important;
  font-weight: 500 !important;
  color: #94a3b8 !important;
  opacity: 0.6 !important;
}

.form-control:focus {
  outline: none !important;
  background: white !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
}

/* Select Dropdown - Custom Arrow */
.form-select,
select.form-select {
  width: 100% !important;
  background-color: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 1rem !important;
  padding: 14px 44px 14px 18px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
  cursor: pointer !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 18px !important;
  transition: all 0.3s ease !important;
  height: auto !important;
}

.form-select:focus {
  outline: none !important;
  background-color: white !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
}

/* Input Group - Button INSIDE input */
.input-group {
  position: relative !important;
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
}

.input-group .form-control {
  border-radius: 1rem !important;
  padding-right: 70px !important;
  width: 100% !important;
  flex: 1 1 auto !important;
  position: relative !important;
  z-index: 1 !important;
}

.input-group .btn,
.input-group button {
  position: absolute !important;
  right: 4px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: #e2e8f0 !important;
  border: none !important;
  border-radius: 0.75rem !important;
  padding: 8px 14px !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  color: #64748b !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.3s ease !important;
  z-index: 10 !important;
  height: auto !important;
  width: auto !important;
  min-width: auto !important;
  pointer-events: auto !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.input-group .btn:hover,
.input-group button:hover {
  background: #3b82f6 !important;
  color: white !important;
}

/* Fix row gaps to prevent slipping */
.row.g-16 {
  --bs-gutter-x: 16px !important;
  --bs-gutter-y: 24px !important;
  margin-bottom: 0 !important;
}

.row.g-16 > [class*="col"] {
  margin-bottom: 0 !important;
}

/* Radio Buttons - v12 Spec with Animation */
.form-check {
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 4px 0 !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  margin: 0 !important;
}

.form-check:hover {
  background: transparent !important;
}

.form-check-input {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  margin: 0 !important;
  border: 2px solid #cbd5e1 !important;
  background: white !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  cursor: pointer !important;
  position: relative !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  flex-shrink: 0 !important;
}

.form-check-input[type="radio"] {
  border-radius: 50% !important;
}

.form-check-input[type="radio"]::after {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 8px !important;
  height: 8px !important;
  border-radius: 50% !important;
  background: #3b82f6 !important;
  transform: translate(-50%, -50%) scale(0) !important;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.form-check-input[type="radio"]:checked {
  border-color: #3b82f6 !important;
  background: white !important;
}

.form-check-input[type="radio"]:checked::after {
  transform: translate(-50%, -50%) scale(1) !important;
}

/* Checkbox - v12 Spec */
.form-check-input[type="checkbox"] {
  border-radius: 6px !important;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
}

.form-check-input[type="checkbox"]:checked {
  background-color: #3b82f6 !important;
  border-color: #3b82f6 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M5 13l4 4L19 7'%3E%3C/path%3E%3C/svg%3E") !important;
  background-size: 12px !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

.form-check-label {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #475569 !important;
  cursor: pointer !important;
  line-height: 1.4 !important;
}

/* Product Rows - v12 style */
.product-row {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 1.5rem !important;
  padding: 24px !important;
  margin-bottom: 16px !important;
  transition: all 0.3s ease !important;
}

.product-row:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

/* Add Product Button - v12 style */
.add-product-btn {
  width: 100% !important;
  background: transparent !important;
  border: 2px dashed #e2e8f0 !important;
  border-radius: 1.5rem !important;
  padding: 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #94a3b8 !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
}

.add-product-btn:hover {
  background: #f8fafc !important;
  border-color: #3b82f6 !important;
  color: #3b82f6 !important;
}

/* Section dividers */
.border-top {
  border-top: 1px solid #f1f5f9 !important;
}

/* ========================================
   Button Systems v12.0
   ======================================== */

/* 7.1 Primary Button (Основное действие) */
.btn-primary,
.btn-primary-600 {
  background: #3b82f6 !important;
  color: white !important;
  border: none !important;
  border-radius: 1rem !important;
  padding: 16px 40px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 10px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.2em !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn-primary:hover,
.btn-primary-600:hover {
  background: #2563eb !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 20px 40px -10px rgba(59, 130, 246, 0.3) !important;
}

/* 7.2 Massive CTA Button */
.btn-massive-cta {
  background: #3b82f6 !important;
  color: white !important;
  border: none !important;
  border-radius: 2.5rem !important;
  padding: 32px 64px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 12px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.3em !important;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.btn-massive-cta:hover {
  background: #2563eb !important;
  transform: translateY(-4px) scale(1.02) !important;
  box-shadow: 0 30px 60px -15px rgba(59, 130, 246, 0.4) !important;
}

/* 7.3 AI Action Button (Smart Gold) */
.btn-ai-action {
  background: #FBBF24 !important;
  color: #0f172a !important;
  border: none !important;
  border-radius: 1rem !important;
  padding: 16px 32px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 10px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.1em !important;
  transition: all 0.3s ease !important;
}

.btn-ai-action:hover {
  background: #f59e0b !important;
  box-shadow: 0 0 25px rgba(251, 191, 36, 0.4) !important;
}

/* 7.4 Outline / Ghost Button */
.btn-outline-primary-600 {
  background: transparent !important;
  color: #3b82f6 !important;
  border: 2px solid #3b82f6 !important;
  border-radius: 1rem !important;
  padding: 14px 24px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 10px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.15em !important;
  transition: all 0.3s ease !important;
}

.btn-outline-primary-600:hover {
  background: #3b82f6 !important;
  color: white !important;
}

.btn-outline-secondary-600,
.btn-outline-neutral-600 {
  background: transparent !important;
  color: #94a3b8 !important;
  border: 2px solid #e2e8f0 !important;
  border-radius: 1rem !important;
  padding: 14px 24px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 10px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.15em !important;
  transition: all 0.3s ease !important;
}

.btn-outline-secondary-600:hover,
.btn-outline-neutral-600:hover {
  background: #f8fafc !important;
  color: #64748b !important;
  border-color: #cbd5e1 !important;
}

/* Preview Panel */
.sticky-preview {
  position: sticky !important;
  top: 100px !important;
  border-radius: 2rem !important;
  overflow: hidden !important;
}

/* Modal - v12 style */
.modal-content {
  border-radius: 2rem !important;
  border: 1px solid #f1f5f9 !important;
  overflow: hidden !important;
}

.modal-header {
  padding: 20px 28px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  background: #f8fafc !important;
}

.modal-title {
  font-size: 12px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.15em !important;
  color: #0f172a !important;
}

.modal-body {
  padding: 28px !important;
}

.modal-footer {
  padding: 20px 28px !important;
  border-top: 1px solid #f1f5f9 !important;
  background: #f8fafc !important;
}

/* Organization/Contractor items in modals */
.organization-item,
.contractor-item {
  background: #f8fafc !important;
  border: 2px solid #f1f5f9 !important;
  border-radius: 1.5rem !important;
  padding: 20px !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
}

.organization-item:hover,
.contractor-item:hover {
  background: #f1f5f9 !important;
  border-color: #3b82f6 !important;
}

.organization-item.selected,
.contractor-item.selected {
  background: #eff6ff !important;
  border-color: #3b82f6 !important;
}

/* Remove button v12 */
.btn.remove-product,
.product-row .btn.remove-product {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  background: #fef2f2 !important;
  border: none !important;
  border-radius: 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #ef4444 !important;
  padding: 0 !important;
  transition: all 0.2s ease !important;
}

.btn.remove-product:hover,
.product-row .btn.remove-product:hover {
  background: #fee2e2 !important;
}

/* UPD Preview styling */
.upd-preview {
  background: white !important;
  border: 1px solid #e5e7eb !important;
  font-size: 11px !important;
  border-radius: 12px !important;
}

.upd-preview table {
  width: 100%;
  border-collapse: collapse;
}

.upd-preview th, .upd-preview td {
  border: 1px solid #000;
  padding: 4px 6px;
  vertical-align: top;
}

.upd-preview .header-cell {
  background: #f3f4f6;
  font-weight: 600;
}

.upd-preview .small-text {
  font-size: 9px;
  color: #666;
}

/* Row gaps adjustment */
.row.g-16 > [class*="col"] {
  display: flex;
  flex-direction: column;
}

.row.g-16 > [class*="col"] > .form-label {
  min-height: auto !important;
  display: block !important;
  margin-bottom: 8px !important;
}

.row.g-16 > [class*="col"] > .form-control,
.row.g-16 > [class*="col"] > .form-select,
.row.g-16 > [class*="col"] > .input-group {
  margin-top: auto;
}

/* Form check in flex containers */
.d-flex.flex-wrap.gap-28 > .form-check {
  margin: 0 !important;
}

/* Footer for form */
.card-footer,
.form-footer {
  padding: 28px !important;
  border-top: 1px solid #f1f5f9 !important;
  background: transparent !important;
}

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

.spin {
  animation: spin 0.5s linear infinite;
}

@media print {
  .no-print {
    display: none !important;
  }
  .upd-preview {
    border: none;
    box-shadow: none;
  }
}

/* Force layout reset - sidebar fixed, main with margin */
body.constructor-page-v12 {
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100vh !important;
}

/* Sidebar fixed on left */
body.constructor-page-v12 aside.sidebar-v12 {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 320px !important;
  height: 100vh !important;
  z-index: 50 !important;
  overflow-y: auto !important;
}

/* Main content with left margin */
body.constructor-page-v12 .dashboard-main-v12 {
  margin-left: 320px !important;
  min-height: 100vh !important;
  padding-top: 0 !important;
  margin-top: 0 !important;
  position: relative !important;
}

/* Header at top of main */
body.constructor-page-v12 .dashboard-header-v12 {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* Footer - fix styles inside dashboard */
body.constructor-page-v12 .footer-v12 {
  margin-left: 0 !important;
  width: 100% !important;
  padding: 48px 0 24px !important;
  margin-top: 48px !important;
}

body.constructor-page-v12 .footer-v12 .footer-nav-v12 h4 {
  font-size: 9px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.2em !important;
  color: #0f172a !important;
  margin-bottom: 16px !important;
}

body.constructor-page-v12 .footer-v12 .footer-nav-v12 ul {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.constructor-page-v12 .footer-v12 .footer-nav-v12 li {
  margin-bottom: 10px !important;
}

body.constructor-page-v12 .footer-v12 .footer-nav-v12 a {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #64748b !important;
  text-decoration: none !important;
}

body.constructor-page-v12 .footer-v12 .footer-nav-v12 a:hover {
  color: #3b82f6 !important;
}

@media (max-width: 1023px) {
  body.constructor-page-v12 aside.sidebar-v12 {
    position: fixed !important;
    transform: translateX(-100%) !important;
    z-index: 1000 !important;
    height: 100vh !important;
  }
  body.constructor-page-v12.sidebar-open aside.sidebar-v12 {
    transform: translateX(0) !important;
  }
  body.constructor-page-v12 .dashboard-main-v12 {
    margin-left: 0 !important;
  }
}

/* Fix z-index для ВСЕХ модальных окон, попапов и overlays */
/* Устанавливаем максимально высокие значения */
.modal,
#selectCompanyModal,
#selectContractorModal,
#previewModal {
  z-index: 999999 !important;
  position: fixed !important;
}

.modal-backdrop,
.modal-backdrop.show {
  z-index: 999998 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
}

.modal-dialog {
  z-index: 1000000 !important;
  position: relative !important;
  margin: 1.75rem auto !important;
}

.modal.show {
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

.modal.show .modal-dialog {
  transform: none !important;
}

.flatpickr-calendar {
  z-index: 1000000 !important;
  position: absolute !important;
}

.flatpickr-calendar.open {
  z-index: 1000000 !important;
  position: absolute !important;
}

/* Bootstrap dropdowns */
.dropdown-menu {
  z-index: 1000000 !important;
}

/* Tooltips и popovers */
.tooltip {
  z-index: 1000000 !important;
}

.popover {
  z-index: 1000000 !important;
}

/* Select2 и другие селекты */
.select2-container,
.select2-dropdown {
  z-index: 1000000 !important;
}

/* Общие overlay классы */
.overlay,
.popup,
.dialog {
  z-index: 999999 !important;
}

/* Понижаем z-index для всех остальных элементов страницы */
body.constructor-page-v12 .sidebar-v12,
body.constructor-page-v12 .header-v12,
body.constructor-page-v12 .dashboard-main-v12 {
  z-index: 1 !important;
  position: relative !important;
}

/* Убираем transform у всех родителей, которые могут создавать stacking context */
body.constructor-page-v12,
body.constructor-page-v12 * {
  transform: none !important;
}

/* ========================================
   UPD Wizard Styles (v12)
   ======================================== */

/* Wizard Trigger */
.wizard-trigger-wrapper {
  background: rgba(251, 191, 36, 0.05);
  border: 2px dashed rgba(251, 191, 36, 0.3);
  border-radius: 1.5rem;
  padding: 20px 28px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.wizard-trigger-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.wizard-trigger-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #FBBF24 0%, #f59e0b 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wizard-trigger-icon svg {
  width: 26px;
  height: 26px;
  color: #0f172a;
}

.wizard-trigger-text {
  flex: 1;
}

.wizard-trigger-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.wizard-trigger-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #10b981;
  color: white;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 8px;
}

.wizard-trigger-badge svg {
  width: 10px;
  height: 10px;
}

.wizard-trigger-subtitle {
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

.wizard-trigger-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  padding: 10px 28px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.wizard-trigger-btn svg {
  width: 18px;
  height: 18px;
}

/* Wizard Modal */
#wizardModal .modal-dialog {
  max-width: 1100px;
}

#wizardModal .modal-content {
  border-radius: 2rem !important;
  border: none !important;
  overflow: hidden;
}

#wizardModal .modal-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  background-image: 
    radial-gradient(circle, rgba(59, 130, 246, 0.4) 1px, transparent 1px),
    linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  background-size: 24px 24px, 100% 100% !important;
  color: white !important;
  border-bottom: none !important;
  padding: 28px 36px 20px !important;
}

#wizardModal .modal-title {
  font-size: 13px !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.15em !important;
  color: white !important;
}

#wizardModal .btn-close {
  filter: invert(1) !important;
  opacity: 0.7 !important;
}

/* Stepper */
.wizard-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 36px 28px;
  background-color: #0f172a;
  background-image: 
    radial-gradient(circle, rgba(59, 130, 246, 0.4) 1px, transparent 1px),
    linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  background-size: 24px 24px, 100% 100%;
  position: relative;
}

.wizard-stepper::after {
  content: '';
  position: absolute;
  top: 54px;
  left: 36px;
  right: 36px;
  height: 2px;
  background: #1e293b;
  z-index: 0;
}

.wizard-step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
  flex: 1;
}

.wizard-step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1e293b;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.wizard-step-item.active .wizard-step-circle {
  background: #3b82f6;
  color: white;
}

.wizard-step-item.completed .wizard-step-circle {
  background: #10b981;
  color: white;
}

.wizard-step-label {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  text-align: center;
  white-space: nowrap;
}

.wizard-step-item.active .wizard-step-label {
  color: #3b82f6;
}

.wizard-step-item.completed .wizard-step-label {
  color: #10b981;
}

/* Progress Bar */
.wizard-progress-bar {
  height: 3px;
  background: #1e293b;
}

.wizard-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
  transition: width 0.4s ease;
}

/* Modal Body */
#wizardModal .modal-body {
  padding: 0 !important;
  background: #f8fafc;
}

.wizard-step-container {
  padding: 36px;
  min-height: 420px;
  background: white;
}

.wizard-step {
  display: none;
}

.wizard-step.active {
  display: block;
}

.wizard-step-title {
  font-size: 22px;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 6px;
}

.wizard-step-subtitle {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 28px;
}

/* Company Cards */
.wizard-company-card {
  display: none;
  margin-top: 20px;
  padding: 18px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.wizard-company-card.show {
  display: block;
}

.wizard-company-header {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.wizard-company-icon {
  width: 44px;
  height: 44px;
  background: #3b82f6;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wizard-company-icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.wizard-company-info {
  flex: 1;
}

.wizard-company-name {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}

.wizard-company-details {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.wizard-company-detail {
  font-size: 12px;
  color: #64748b;
}

.wizard-company-address {
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
}

/* Products */
.wizard-product-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
}

.add-product-btn {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  color: #3b82f6;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

/* Totals */
.wizard-totals {
  margin-top: 20px;
  padding: 18px;
  background: #f8fafc;
  border-radius: 12px;
}

.wizard-totals-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  color: #64748b;
}

.wizard-totals-row.total {
  border-top: 2px solid #cbd5e1;
  margin-top: 8px;
  padding-top: 14px;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
}

/* Final Actions */
.wizard-final-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 28px;
}

.wizard-action-btn {
  padding: 22px;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  background: white;
}

.wizard-action-btn.primary {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.04);
}

.wizard-action-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  background: #f8fafc;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wizard-action-icon svg {
  width: 26px;
  height: 26px;
  color: #3b82f6;
}

.wizard-action-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}

.wizard-action-desc {
  font-size: 12px;
  color: #64748b;
}

/* Footer */
#wizardModal .modal-footer {
  padding: 18px 36px !important;
  border-top: 1px solid #e2e8f0 !important;
  background: white !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}


/* Section spacing in wizard steps */
.wizard-step .mb-24 {
  margin-bottom: 24px !important;
  padding-bottom: 24px !important;
  border-bottom: 1px solid #e2e8f0;
}

.wizard-step h5 {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 16px;
}

/* ========================================
   Responsive / Mobile Styles
   ======================================== */

@media (max-width: 768px) {
  /* Wizard Trigger */
  .wizard-trigger-wrapper {
    flex-direction: column;
    padding: 16px 20px;
    gap: 16px;
  }
  
  .wizard-trigger-content {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  
  .wizard-trigger-icon {
    margin: 0 auto;
  }
  
  .wizard-trigger-title {
    font-size: 15px;
  }
  
  .wizard-trigger-subtitle {
    font-size: 12px;
  }
  
  .wizard-trigger-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 24px;
  }
  
  /* Modal */
  #wizardModal .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  
  #wizardModal .modal-content {
    border-radius: 1.5rem !important;
  }
  
  #wizardModal .modal-header {
    padding: 16px 16px 12px !important;
  }
  
  #wizardModal .modal-title {
    font-size: 10px !important;
    letter-spacing: 0.08em !important;
  }
  
  #wizardModal .btn-close {
    width: 20px !important;
    height: 20px !important;
    background-size: 12px !important;
  }
  
  /* Stepper */
  .wizard-stepper {
    padding: 12px 16px 16px;
    overflow-x: auto;
    scrollbar-width: thin;
    -ms-overflow-style: auto;
    background-size: 20px 20px, 100% 100% !important;
  }
  
  .wizard-stepper::-webkit-scrollbar {
    height: 3px;
  }
  
  .wizard-stepper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
  }
  
  .wizard-stepper::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 3px;
  }
  
  .wizard-stepper::after {
    display: none;
  }
  
  .wizard-step-item {
    min-width: 48px;
    flex-shrink: 0;
    gap: 6px;
  }
  
  .wizard-step-circle {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }
  
  .wizard-step-label {
    font-size: 8px;
    max-width: 48px;
    white-space: normal;
    line-height: 1.1;
    text-align: center;
    word-break: break-word;
  }
  
  /* Progress Bar */
  .wizard-progress-bar {
    height: 2px;
  }
  
  /* Step Container */
  .wizard-step-container {
    padding: 24px 20px;
    min-height: auto;
  }
  
  .wizard-step-title {
    font-size: 19px;
  }
  
  .wizard-step-subtitle {
    font-size: 12px;
    margin-bottom: 20px;
  }
  
  /* Form Elements */
  #wizardModal .form-label {
    font-size: 12px;
    margin-bottom: 6px;
  }
  
  #wizardModal .form-control,
  #wizardModal .form-select {
    padding: 10px 14px;
    font-size: 14px;
  }
  
  #wizardModal .input-group .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  /* Company Cards */
  .wizard-company-card {
    padding: 14px;
  }
  
  .wizard-company-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .wizard-company-icon {
    width: 40px;
    height: 40px;
  }
  
  .wizard-company-name {
    font-size: 14px;
  }
  
  .wizard-company-details {
    flex-direction: column;
    gap: 8px;
  }
  
  /* Products */
  .wizard-product-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
    background: #f8fafc;
    border-radius: 10px;
    margin-bottom: 12px;
  }
  
  .wizard-product-row > div:last-child {
    display: flex;
    justify-content: center;
  }
  
  /* Totals */
  .wizard-totals {
    padding: 14px;
  }
  
  .wizard-totals-row {
    font-size: 12px;
  }
  
  .wizard-totals-row.total {
    font-size: 15px;
  }
  
  /* Final Actions */
  .wizard-final-actions {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .wizard-action-btn {
    padding: 18px;
  }
  
  .wizard-action-icon {
    width: 48px;
    height: 48px;
  }
  
  .wizard-action-title {
    font-size: 14px;
  }
  
  .wizard-action-desc {
    font-size: 11px;
  }
  
  /* Footer */
  #wizardModal .modal-footer {
    padding: 14px 20px !important;
    flex-wrap: wrap;
  }
  
  #wizardModal .modal-footer .btn {
    font-size: 13px;
    padding: 10px 20px !important;
  }
  
  #wizard-btn-back,
  #wizard-btn-skip,
  #wizard-btn-next {
    flex: 1 1 auto;
    min-width: auto;
  }
  
  #wizard-btn-next {
    flex: 2 1 auto;
  }
  
  /* Hide spacer on mobile */
  #wizardModal .modal-footer > div[style*="flex: 1"] {
    display: none !important;
  }
  
  /* Grid adjustments */
  .wizard-step .row.g-16 > [class*="col-md-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  .wizard-step .mb-24 {
    padding-bottom: 16px;
    margin-bottom: 16px !important;
  }
  
  .wizard-step h5 {
    font-size: 13px;
    margin-bottom: 12px;
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  .wizard-trigger-title {
    font-size: 14px;
  }
  
  .wizard-trigger-badge {
    font-size: 8px;
    padding: 3px 8px;
  }
  
  #wizardModal .modal-dialog {
    margin: 0.25rem;
    max-width: calc(100% - 0.5rem);
  }
  
  #wizardModal .modal-header {
    padding: 14px 14px 10px !important;
  }
  
  #wizardModal .modal-title {
    font-size: 9px !important;
    letter-spacing: 0.06em !important;
  }
  
  #wizardModal .btn-close {
    width: 18px !important;
    height: 18px !important;
    background-size: 10px !important;
  }
  
  .wizard-stepper {
    padding: 10px 12px 14px;
  }
  
  .wizard-step-item {
    min-width: 42px;
    gap: 4px;
  }
  
  .wizard-step-circle {
    width: 26px;
    height: 26px;
    font-size: 10px;
  }
  
  .wizard-step-label {
    font-size: 7px;
    max-width: 42px;
    line-height: 1;
  }
  
  .wizard-step-container {
    padding: 20px 16px;
  }
  
  .wizard-step-title {
    font-size: 17px;
  }
  
  #wizardModal .modal-footer {
    padding: 12px 16px !important;
  }
  
  #wizardModal .modal-footer .btn {
    font-size: 12px;
    padding: 9px 16px !important;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  #wizardModal .modal-dialog {
    max-width: 90%;
  }
  
  .wizard-step-container {
    padding: 32px 28px;
  }
  
  .wizard-product-row {
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
    gap: 8px;
  }
  
  #wizardModal .modal-header {
    padding: 24px 28px 18px !important;
  }
  
  #wizardModal .modal-footer {
    padding: 16px 28px !important;
  }
  
  .wizard-stepper {
    padding: 18px 28px 24px;
  }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  #wizardModal .modal-dialog {
    margin: 0.5rem auto;
  }
  
  .wizard-step-container {
    padding: 20px 24px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
  }
  
  .wizard-stepper {
    padding: 12px 20px 16px;
  }
  
  #wizardModal .modal-header {
    padding: 16px 20px 12px !important;
  }
  
  #wizardModal .modal-footer {
    padding: 12px 20px !important;
  }
}


/* UPD Status Alert - Mobile Responsive */
.alert.alert-secondary-100 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

@media (max-width: 768px) {
  .alert.alert-secondary-100 {
    padding: 12px 14px !important;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  
  .alert.alert-secondary-100 span.text-sm {
    font-size: 12px !important;
    font-weight: 600;
  }
  
  .alert.alert-secondary-100 #upd-status-display {
    font-size: 13px !important;
    line-height: 1.4;
  }
  
  .alert.alert-secondary-100 span.text-xs {
    font-size: 11px !important;
    margin-left: 0 !important;
    display: block;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .alert.alert-secondary-100 {
    padding: 10px 12px !important;
  }
  
  .alert.alert-secondary-100 span.text-sm {
    font-size: 11px !important;
  }
  
  .alert.alert-secondary-100 #upd-status-display {
    font-size: 12px !important;
  }
  
  .alert.alert-secondary-100 span.text-xs {
    font-size: 10px !important;
  }
}


/* Very small screens - iPhone SE, small Android */
@media (max-width: 375px) {
  #wizardModal .modal-title {
    font-size: 8px !important;
    letter-spacing: 0.05em !important;
  }
  
  .wizard-stepper {
    padding: 8px 10px 12px;
    gap: 4px;
  }
  
  .wizard-step-item {
    min-width: 38px;
    gap: 3px;
  }
  
  .wizard-step-circle {
    width: 24px;
    height: 24px;
    font-size: 9px;
  }
  
  .wizard-step-label {
    font-size: 6px;
    max-width: 38px;
    line-height: 0.9;
  }
}

