/* ─── DESIGN TOKENS ───────────────────────────────────────────── */
:root {
  --primary: #0f172a;
  --primary-light: #1e293b;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --accent-light: #ffedd5;
  --success: #10b981;
  --success-light: #ecfdf5;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-light: #94a3b8;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── RESET ───────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.4rem;
  color: white;
  flex-shrink: 0;
  letter-spacing: -1px;
  box-shadow: 0 4px 10px rgba(249, 115, 22, 0.3);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: white;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  margin-top: 2px;
}

.doc-meta {
  text-align: right;
}

.doc-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  margin-bottom: 4px;
  box-shadow: 0 2px 5px rgba(249, 115, 22, 0.2);
}

.doc-date {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
}

/* ─── BODY WRAPPER ────────────────────────────────────────────── */
.page-body {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 20px 120px;
}

@media (min-width: 768px) {
  .page-body {
    padding: 32px 32px 60px;
  }
}

/* ─── INTRO ───────────────────────────────────────────────────── */
.intro-block {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.7;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.intro-block b {
  color: var(--accent);
  font-weight: 600;
}

/* ─── CARD ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: #cbd5e1;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-subtle);
}

.card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 24px;
}

/* ─── CONFIG GRID ─────────────────────────────────────────────── */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (min-width: 580px) {
  .config-grid {
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
  }
}

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

@media (min-width: 580px) {
  .span-2 {
    grid-column: span 1;
  }
}

/* ─── FORM FIELDS ─────────────────────────────────────────────── */
.field-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.field-group input,
.field-group select {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-card);
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.field-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23475569' d='M5 7L0.67 2h8.66z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.field-group input:focus,
.field-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.15);
}

.field-group input::placeholder {
  color: var(--text-light);
}

/* ─── CATALOG TOOLBAR ─────────────────────────────────────────── */
.catalog-toolbar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--bg-subtle);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--text-secondary);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  min-height: 40px;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg-card);
  transition: var(--transition);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.15);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ─── TABLE ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

thead th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 14px 20px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 4px 5px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: 0.9rem;
}

tbody .col-weight {
  text-align: center;
}

tbody .col-thumb {
  width: 60px;
  text-align: center;
}

.product-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  display: inline-block;
}

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

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background: #f8fafc;
}

tbody td strong {
  color: var(--text);
  font-weight: 600;
}

/* ─── ORIGIN CHIPS ────────────────────────────────────────────── */
.origin-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-top: 6px;
}

.origin-label {
  color: var(--text-light);
  margin-right: 4px;
  font-size: 0.75rem;
}

@media (max-width: 767px) {
  .origin-label {
    color: rgba(255, 255, 255, 0.6);
  }
}

.origin-chip {
  cursor: pointer;
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: 1.5px solid #cbd5e1;
  background: transparent;
  color: var(--text-secondary);
  transition: var(--transition);
  user-select: none;
  text-transform: uppercase;
}

.origin-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.origin-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 5px rgba(249, 115, 22, 0.2);
}

/* ─── MOBILE CARD TABLE ───────────────────────────────────────── */
@media (max-width: 767px) {
  .table-wrap {
    overflow-x: visible;
  }

  table {
    min-width: unset !important;
  }

  thead {
    display: none;
  }

  tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
  }

  tbody tr:hover {
    background: var(--bg-card);
  }

  tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
  }

  tbody td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-right: 16px;
  }

  tbody td.col-name {
    background: var(--primary);
    color: white;
    border-bottom: 3px solid var(--accent);
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 18px 16px;
  }

  tbody td.col-name::before {
    display: none;
  }

  tbody td.col-name strong {
    color: white;
    font-size: 1.05rem;
  }

  tbody td.col-sku,
  tbody td.col-weight,
  tbody td.col-moq,
  tbody td.col-thumb {
    display: none;
  }

  tbody td.col-qty {
    gap: 16px;
  }

  tbody td.col-qty .qty-input {
    width: 100px;
    height: 44px;
    font-size: 1.1rem;
  }

  tbody td.col-subtotal {
    font-size: 1.05rem;
    font-weight: 700;
    background: var(--bg-subtle);
    border-bottom: none;
  }

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

/* ─── QTY INPUT ───────────────────────────────────────────────── */
.qty-input {
  width: 72px;
  height: 38px;
  padding: 4px 8px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  background: var(--bg-card);
  transition: var(--transition);
}

.qty-input:hover {
  border-color: var(--text-light);
}

.qty-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.15);
}

/* ─── PAGINATION ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 18px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-subtle);
}

.pg-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pg-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.pg-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 2px 5px rgba(249, 115, 22, 0.2);
}

.pg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--border-light);
}

/* ─── BOTTOM ROW ──────────────────────────────────────────────── */
.bottom-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap-reverse;
}

.actions {
  flex-shrink: 0;
  display: flex;
  gap: 12px;
}

/* ─── SUMMARY BOX ─────────────────────────────────────────────── */
.summary-box {
  flex: 1;
  min-width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: var(--transition);
}

.summary-box:hover {
  box-shadow: var(--shadow-lg);
}

.summary-head {
  padding: 16px 24px;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}

.summary-row .s-label {
  color: var(--text-secondary);
}

.summary-row .s-value {
  font-weight: 600;
}

.summary-shipping {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafafa;
}

.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-top: 2px solid var(--primary);
  background: var(--bg-subtle);
  font-weight: 700;
}

.summary-total .total-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-total .total-value {
  font-size: 1.4rem;
  color: var(--success);
}

.summary-roi {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--success-light);
  border-top: 1px dashed #a7f3d0;
  font-size: 0.9rem;
}

.summary-roi .roi-label {
  color: #065f46;
  font-weight: 600;
}

.summary-roi .roi-value {
  color: #047857;
  font-weight: 700;
}

/* ─── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  min-height: 42px;
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
  min-height: 36px;
}

/* ─── CARRIER SELECT ──────────────────────────────────────────── */
#carrierSelect {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: white;
  transition: var(--transition);
}

#carrierSelect:focus {
  outline: none;
  border-color: var(--accent);
}

.carrier-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ─── TERMS ───────────────────────────────────────────────────── */
.terms-block {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  padding: 20px 24px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 24px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}

.terms-block .terms-title {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 10px;
  display: block;
}

.terms-block ul {
  padding-left: 20px;
}

.terms-block li {
  margin-bottom: 6px;
}

/* ─── SIGNATURES ──────────────────────────────────────────────── */
.signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  margin-top: 100px;
  margin-bottom: 16px;
  text-align: center;
}

.sig-box {
  border-top: 1.5px solid var(--primary);
  padding-top: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

/* ─── MOBILE STICKY BAR ───────────────────────────────────────── */
.mobile-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  padding: 14px 20px;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

@media (max-width: 767px) {
  .table-wrap {
    padding: 10px;
  }

  .mobile-bar {
    display: flex;
  }
}

.mb-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.5);
  display: block;
  margin-bottom: 2px;
}

.mb-total {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
}

/* ─── PRINT ───────────────────────────────────────────────────── */
@media print {
  body {
    background: white;
    color: black;
  }

  .page-header {
    position: relative;
    background: transparent;
    border-bottom: 2px solid black;
    box-shadow: none;
  }

  .brand-name,
  .brand-sub,
  .doc-badge,
  .doc-date {
    color: black !important;
  }

  .brand-logo {
    border: 2px solid black;
    color: black;
    background: transparent;
    box-shadow: none;
  }

  .mobile-bar {
    display: none !important;
  }

  .page-body {
    padding: 0;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ccc;
    background: white;
  }

  .qty-input {
    border: 1px solid #999;
    background: white;
  }

  button,
  .btn,
  #btnRefreshShipping {
    display: none !important;
  }

  .intro-block {
    display: none;
  }

  tbody tr {
    break-inside: avoid;
  }
}