/* ==========================================================================
   Modern Return & Exchange (RX) Design System
   ========================================================================== */

:root {
  --rx-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --rx-primary: #4f46e5;
  --rx-primary-hover: #4338ca;
  --rx-primary-light: #eef2ff;
  --rx-primary-border: #c7d2fe;

  --rx-emerald: #10b981;
  --rx-emerald-hover: #059669;
  --rx-emerald-light: #ecfdf5;
  --rx-emerald-border: #a7f3d0;
  --rx-emerald-text: #065f46;

  --rx-rose: #e11d48;
  --rx-rose-hover: #be123c;
  --rx-rose-light: #fff1f2;
  --rx-rose-border: #fecdd3;
  --rx-rose-text: #9f1239;

  --rx-amber: #f59e0b;
  --rx-amber-light: #fffbeb;
  --rx-amber-border: #fde68a;
  --rx-amber-text: #92400e;

  --rx-slate-50: #f8fafc;
  --rx-slate-100: #f1f5f9;
  --rx-slate-200: #e2e8f0;
  --rx-slate-300: #cbd5e1;
  --rx-slate-400: #94a3b8;
  --rx-slate-500: #64748b;
  --rx-slate-600: #475569;
  --rx-slate-700: #334155;
  --rx-slate-800: #1e293b;
  --rx-slate-900: #0f172a;

  --rx-card-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --rx-card-shadow-hover: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --rx-radius: 10px;
  --rx-radius-sm: 6px;
  --rx-radius-lg: 14px;
}

.rx {
  font-family: var(--rx-font);
  color: var(--rx-slate-800);
  font-size: 13px;
  line-height: 1.5;
  padding-bottom: 24px;
}

.rx * {
  box-sizing: border-box;
}

/* Header */
.rx-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: #ffffff;
  border: 1px solid var(--rx-slate-200);
  border-radius: var(--rx-radius);
  margin-bottom: 16px;
  box-shadow: var(--rx-card-shadow);
}

.rx-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.rx-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.rx-header-icon.is-exchange {
  background: var(--rx-primary-light);
  color: var(--rx-primary);
  border: 1px solid var(--rx-primary-border);
}

.rx-header-icon.is-return {
  background: var(--rx-rose-light);
  color: var(--rx-rose);
  border: 1px solid var(--rx-rose-border);
}

.rx-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--rx-slate-900);
  margin: 0 0 3px;
  letter-spacing: -0.01em;
}

.rx-header .rx-meta {
  font-size: 12.5px;
  color: var(--rx-slate-500);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rx-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--rx-slate-100);
  color: var(--rx-slate-700);
  border: 1px solid var(--rx-slate-200);
}

.rx-close {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--rx-slate-200);
  background: #ffffff;
  color: var(--rx-slate-600);
  border-radius: var(--rx-radius-sm);
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.rx-close:hover {
  background: var(--rx-slate-50);
  color: var(--rx-slate-900);
  border-color: var(--rx-slate-300);
}

/* Grid Layout */
.rx-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: start;
}

@media (min-width: 1400px) {
  .rx-grid {
    grid-template-columns: 1fr 370px;
    gap: 20px;
  }
}

/* Card */
.rx-card {
  background: #ffffff;
  border: 1px solid var(--rx-slate-200);
  border-radius: var(--rx-radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--rx-card-shadow);
}

.rx-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rx-slate-100);
}

.rx-card h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rx-slate-500);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rx-col-summary {
  position: sticky;
  top: 16px;
}

/* Table Design */
.rx-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rx-slate-200);
  border-radius: var(--rx-radius-sm);
  background: #ffffff;
}

.rx-items-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 12.5px;
}

.rx-items-table thead th {
  background: var(--rx-slate-50);
  color: var(--rx-slate-600);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid var(--rx-slate-300);
  white-space: nowrap;
}

.rx-items-table th.rx-col-sl,
.rx-items-table td.rx-col-sl {
  width: 44px;
  text-align: center;
  color: var(--rx-slate-400);
  font-weight: 600;
}

.rx-items-table th.rx-col-num,
.rx-items-table td.rx-col-num {
  text-align: center;
}

.rx-items-table tbody tr {
  background: #ffffff;
  border-bottom: 2px solid var(--rx-slate-200);
  transition: background-color 0.15s ease;
}

.rx-items-table tbody tr:hover {
  background: var(--rx-slate-50);
}

.rx-items-table tbody tr:last-child {
  border-bottom: none;
}

.rx-items-table tbody tr.is-empty {
  opacity: 0.6;
  background: #fafafa;
}

.rx-items-table td {
  padding: 14px 14px;
  vertical-align: middle;
  border-bottom: 2px solid var(--rx-slate-200);
}

.rx-product-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--rx-slate-900);
  margin-bottom: 2px;
}

.rx-line-note {
  font-size: 11px;
  color: var(--rx-rose);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.rx-variation-badge {
  display: inline-flex;
  align-items: center;
  background: var(--rx-primary-light);
  border: 1px solid var(--rx-primary-border);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--rx-primary);
  white-space: nowrap;
}

.rx-no-variation {
  font-size: 11.5px;
  color: var(--rx-slate-400);
  font-style: italic;
}

/* Multi-Unit Replace List in 2 Columns */
.rx-unit-select-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  min-width: 0;
  width: 100%;
  max-width: 580px;
}

@media (max-width: 991px) {
  .rx-unit-select-list {
    grid-template-columns: 1fr;
  }
}

.rx-unit-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--rx-slate-300);
  border-bottom: 2px solid #94a3b8;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  transition: all 0.2s ease;
}

.rx-unit-item.is-replaced {
  border-color: var(--rx-emerald-border);
  border-bottom: 2px solid #10b981;
  background: var(--rx-emerald-light);
}

.rx-unit-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--rx-slate-600);
  background: var(--rx-slate-100);
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 2px 5px;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
  box-sizing: border-box;
}

.rx-unit-item.is-replaced .rx-unit-tag {
  background: #ffffff;
  color: var(--rx-emerald-text);
  border: 1px solid var(--rx-emerald-border);
}

.rx-unit-select {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 30px;
  line-height: 1.3;
  padding: 2px 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--rx-slate-800);
  border: 1px solid var(--rx-slate-300);
  border-radius: 4px;
  background-color: #ffffff;
  box-sizing: border-box;
  cursor: pointer;
  outline: none;
  text-overflow: ellipsis;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rx-unit-select:focus {
  border-color: var(--rx-primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.rx-unit-item.is-replaced .rx-unit-select {
  border-color: var(--rx-emerald);
  color: var(--rx-emerald-text);
  font-weight: 600;
  background-color: #ffffff;
}

.line-exchange-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--rx-slate-100);
  color: var(--rx-slate-500);
  border: 1px solid var(--rx-slate-200);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.line-exchange-badge.is-active {
  background: var(--rx-emerald-light);
  color: var(--rx-emerald-text);
  border-color: var(--rx-emerald-border);
}

/* Return Page Card Lines */
.rx-line {
  border: 1px solid var(--rx-slate-200);
  border-radius: var(--rx-radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #ffffff;
  box-shadow: var(--rx-card-shadow);
  transition: all 0.15s ease;
}

.rx-line:hover {
  box-shadow: var(--rx-card-shadow-hover);
  border-color: var(--rx-slate-300);
}

.rx-line.is-empty {
  opacity: 0.6;
  background: var(--rx-slate-50);
}

.rx-line-top {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.rx-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--rx-slate-200);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--rx-slate-50);
}

.rx-thumb-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px dashed var(--rx-slate-300);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rx-slate-400);
  font-size: 10px;
  background: var(--rx-slate-50);
  text-align: center;
}

.rx-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  margin: 12px 0 10px;
}

.rx-stat {
  background: var(--rx-slate-50);
  border: 1px solid var(--rx-slate-200);
  border-radius: var(--rx-radius-sm);
  padding: 6px 10px;
  text-align: center;
}

.rx-stat .rx-stat-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rx-slate-500);
  font-weight: 700;
  margin-bottom: 2px;
}

.rx-stat .rx-stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--rx-slate-800);
}

.rx-stat.rx-stat-highlight {
  background: var(--rx-emerald-light);
  border-color: var(--rx-emerald-border);
}

.rx-stat.rx-stat-highlight .rx-stat-label {
  color: var(--rx-emerald-text);
}

.rx-stat.rx-stat-highlight .rx-stat-value {
  color: var(--rx-emerald);
}

.rx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--rx-slate-100);
  padding-top: 12px;
  margin-top: 4px;
}

/* Stepper Quantity Control */
.rx-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rx-slate-300);
  border-radius: var(--rx-radius-sm);
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.rx-qty button {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--rx-slate-50);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  color: var(--rx-slate-700);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.rx-qty button:hover:not(:disabled) {
  background: var(--rx-slate-200);
  color: var(--rx-slate-900);
}

.rx-qty button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.rx-qty input {
  width: 48px;
  height: 32px;
  border: none;
  border-left: 1px solid var(--rx-slate-200);
  border-right: 1px solid var(--rx-slate-200);
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--rx-slate-900);
  -moz-appearance: textfield;
}

.rx-qty input::-webkit-outer-spin-button,
.rx-qty input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rx-max-hint {
  font-size: 11px;
  color: var(--rx-slate-400);
  margin-top: 4px;
}

.rx-warn {
  font-size: 11.5px;
  color: var(--rx-rose);
  font-weight: 600;
  margin-top: 4px;
  display: none;
}

.rx-line-price {
  text-align: right;
}

.rx-line-price .rx-price-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rx-slate-400);
  font-weight: 700;
}

.rx-line-price .rx-price-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--rx-slate-900);
}

/* Summary Card */
.rx-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  color: var(--rx-slate-600);
}

.rx-summary-row.rx-total {
  border-top: 1px dashed var(--rx-slate-200);
  margin-top: 6px;
  padding-top: 12px;
  font-weight: 700;
  font-size: 15px;
  color: var(--rx-slate-900);
}

.rx-summary-row .rx-label {
  color: var(--rx-slate-600);
}

.rx-due-box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0 14px;
}

.rx-due-tile {
  border: 1px solid var(--rx-slate-200);
  border-radius: var(--rx-radius-sm);
  padding: 8px 6px;
  text-align: center;
  background: var(--rx-slate-50);
}

.rx-due-tile .rx-due-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rx-slate-500);
  font-weight: 700;
  margin-bottom: 3px;
  white-space: nowrap;
}

.rx-due-tile .rx-due-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--rx-slate-800);
}

.rx-due-tile.rx-due-adjust .rx-due-value {
  color: var(--rx-rose);
}

.rx-due-tile.rx-due-after {
  background: var(--rx-primary-light);
  border-color: var(--rx-primary-border);
}

.rx-due-tile.rx-due-after .rx-due-value {
  color: var(--rx-primary);
}

/* Form Controls */
.rx-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rx-slate-600);
  margin-bottom: 5px;
  display: block;
}

.rx-input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--rx-slate-300);
  border-radius: var(--rx-radius-sm);
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--rx-slate-800);
  outline: none;
  background: #ffffff;
  transition: all 0.15s ease;
}

.rx-input:focus {
  border-color: var(--rx-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.rx-textarea {
  width: 100%;
  border: 1px solid var(--rx-slate-300);
  border-radius: var(--rx-radius-sm);
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--rx-slate-800);
  resize: vertical;
  outline: none;
  background: #ffffff;
  transition: all 0.15s ease;
}

.rx-textarea:focus {
  border-color: var(--rx-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.rx-fields-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.rx-fields-row + .rx-fields-row {
  margin-top: 10px;
}

/* Action Buttons */
.rx-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--rx-slate-100);
}

.rx-btn {
  border: none;
  border-radius: var(--rx-radius-sm);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.rx-btn-secondary {
  background: #ffffff;
  border: 1px solid var(--rx-slate-300);
  color: var(--rx-slate-700);
}

.rx-btn-secondary:hover {
  background: var(--rx-slate-50);
  border-color: var(--rx-slate-400);
  color: var(--rx-slate-900);
}

.rx-btn-primary {
  background: var(--rx-primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}

.rx-btn-primary:hover {
  background: var(--rx-primary-hover);
}

.rx-btn-return {
  background: var(--rx-rose);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(225, 29, 72, 0.2);
}

.rx-btn-return:hover {
  background: var(--rx-rose-hover);
}

.rx-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.rx-errors {
  background: var(--rx-rose-light);
  border: 1px solid var(--rx-rose-border);
  color: var(--rx-rose-text);
  border-radius: var(--rx-radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
}

@media (max-width: 1024px) {
  .rx-grid {
    grid-template-columns: 1fr;
  }
  .rx-col-summary {
    position: static;
  }
}

@media (max-width: 640px) {
  .rx-fields-row {
    grid-template-columns: 1fr;
  }
  .rx-due-box {
    grid-template-columns: 1fr;
  }
}