/* FulfillmentBridge brand palette, extracted from the real logo:
   primary #009BD5, accent #3AB3E7, wordmark charcoal ~#2B2626 */

:root {
  --brand-primary: #009bd5;
  --brand-primary-dark: #007aa8;
  --brand-accent: #3ab3e7;
  --brand-success: #1aa06d;
  --brand-success-bg: #e7f7f1;
  --brand-danger: #d6403a;
  --brand-danger-bg: #fdeceb;

  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e3e8ed;
  --text: #201c1c;
  --text-muted: #6b7280;
  --text-on-brand: #ffffff;
  --shadow: 0 1px 2px rgba(20, 30, 40, 0.04), 0 8px 24px rgba(20, 30, 40, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
}

[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #171d24;
  --surface-raised: #1d242c;
  --border: #2a333d;
  --text: #eef2f6;
  --text-muted: #8a97a6;
  --brand-success-bg: #103527;
  --brand-danger-bg: #3a1a18;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 12px 32px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html[dir="rtl"] body {
  font-family: "Inter", "Noto Sans Arabic", -apple-system, sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

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

.brand img {
  height: 30px;
  width: auto;
}

.brand-tagline {
  font-size: 12px;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 640px) {
  .brand-tagline {
    display: block;
    border-inline-start: 1px solid var(--border);
    padding-inline-start: 10px;
    margin-inline-start: 2px;
  }
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn,
.lang-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn {
  width: 38px;
}

.icon-btn:hover,
.lang-select:hover {
  border-color: var(--brand-primary);
}

.lang-select {
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
}

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

.sun-icon {
  display: none;
}

[data-theme="dark"] .sun-icon {
  display: block;
}

[data-theme="dark"] .moon-icon {
  display: none;
}

.hero {
  padding: 56px 20px 36px;
  text-align: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-primary) 7%, var(--bg)) 0%, var(--bg) 100%);
}

.hero h1 {
  font-size: clamp(28px, 4vw, 40px);
  margin: 0 0 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 520px;
  margin: 0 auto;
}

.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 72px;
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px;
  border-radius: 999px;
  width: fit-content;
  margin: 0 auto 28px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--brand-primary);
  color: #fff;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 20px;
}

.callout {
  display: flex;
  gap: 12px;
  background: color-mix(in srgb, var(--brand-primary) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand-primary) 25%, var(--border));
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 24px;
}

.callout svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--brand-primary);
  margin-top: 1px;
}

.callout-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 3px;
}

.callout-body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.callout-body code {
  background: color-mix(in srgb, var(--brand-primary) 14%, transparent);
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 600;
  color: var(--brand-primary-dark);
}

[data-theme="dark"] .callout-body code {
  color: var(--brand-accent);
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 28px 0 14px;
}

.card .section-title:first-child {
  margin-top: 0;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 18%, transparent);
}

.field input.test-value {
  border-color: var(--brand-danger);
  background: var(--brand-danger-bg);
}

.submit-btn {
  width: 100%;
  margin-top: 28px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-primary-dark));
  color: #fff;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand-primary) 35%, transparent);
}

.submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand-primary) 45%, transparent);
}

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

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-inline-end: 8px;
  vertical-align: -2px;
}

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

.result-card {
  display: none;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 20px;
  animation: fadeIn 0.35s ease;
}

.result-card.show {
  display: block;
}

.result-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-header.success {
  background: var(--brand-success-bg);
  color: var(--brand-success);
}

.result-header.exception {
  background: var(--brand-danger-bg);
  color: var(--brand-danger);
}

.result-header.pending {
  background: #fff6e0;
  color: #9a6d00;
}

[data-theme="dark"] .result-header.pending {
  background: #3a2f10;
  color: #e6b94f;
}

.result-header svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.result-header-text h3 {
  margin: 0 0 2px;
  font-size: 16px;
}

.result-header-text p {
  margin: 0;
  font-size: 13px;
  opacity: 0.85;
}

.result-body {
  background: var(--surface);
  padding: 20px 24px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.result-row:last-child {
  border-bottom: none;
}

.result-row .label {
  color: var(--text-muted);
}

.result-row .value {
  font-weight: 600;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
}

.result-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 18px 0 4px;
}

.lookup-row {
  display: flex;
  gap: 10px;
}

.lookup-row input {
  flex: 1;
}

.lookup-row button {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  padding: 0 22px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 30px 20px 40px;
}

/* ---------- Auth ---------- */

.auth-card {
  max-width: 420px;
  margin: 0 auto;
}

.auth-title {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 4px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 20px;
}

.auth-card .field {
  margin-bottom: 14px;
}

.auth-error {
  color: var(--brand-danger);
  font-size: 13px;
  min-height: 0;
  margin-top: -4px;
  margin-bottom: 4px;
}

.auth-error:empty {
  display: none;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  margin-top: 18px;
}

.auth-switch a {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-required-card {
  text-align: center;
  padding: 44px 28px;
}

.auth-required-card svg {
  width: 36px;
  height: 36px;
  color: var(--brand-primary);
  margin-bottom: 12px;
}

.auth-required-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.auth-required-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
  max-width: 340px;
  margin: 0 auto;
}

/* ---------- Account area (topbar) ---------- */

.account-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding-inline-end: 4px;
}

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.account-text {
  display: none;
  line-height: 1.25;
}

@media (min-width: 720px) {
  .account-text {
    display: block;
  }
}

.account-text .name {
  font-weight: 700;
}

.account-text .company {
  color: var(--text-muted);
  font-size: 11.5px;
}

.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.nav-btn.primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

.nav-btn.ghost {
  border-color: transparent;
  color: var(--text-muted);
}

/* ---------- Checkbox fields (pickup toggle, new-product toggle, save-as-product) ---------- */

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  margin: 4px 0 16px;
  user-select: none;
}

.checkbox-field input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand-primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------- Repeatable rows (line items, packages) ---------- */

.line-item-row,
.package-row {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

.row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.row-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.remove-row-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.remove-row-btn:hover {
  color: var(--brand-danger);
  background: var(--brand-danger-bg);
}

.line-item-row .grid,
.package-row .grid {
  margin-bottom: 0;
}

.new-product-fields {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.add-row-btn {
  width: 100%;
  background: transparent;
  border: 1.5px dashed var(--border);
  color: var(--brand-primary);
  font-family: inherit;
  font-weight: 700;
  font-size: 13.5px;
  padding: 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 8px;
}

.add-row-btn:hover {
  background: color-mix(in srgb, var(--brand-primary) 6%, transparent);
  border-color: var(--brand-primary);
}

/* ---------- Compliance review ---------- */

.compliance-card {
  border-color: color-mix(in srgb, var(--brand-primary) 30%, var(--border));
  animation: fadeIn 0.3s ease;
}

.review-item {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 14px;
}

.review-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.review-kind-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-primary) 14%, transparent);
  color: var(--brand-primary-dark);
}

[data-theme="dark"] .review-kind-badge {
  color: var(--brand-accent);
}

.review-target {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.confidence-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  margin-inline-start: auto;
}

.confidence-badge.high {
  background: var(--brand-success-bg);
  color: var(--brand-success);
}

.confidence-badge.medium {
  background: #fff6e0;
  color: #9a6d00;
}

[data-theme="dark"] .confidence-badge.medium {
  background: #3a2f10;
  color: #e6b94f;
}

.confidence-badge.low {
  background: var(--brand-danger-bg);
  color: var(--brand-danger);
}

.review-message {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 14px;
}

.review-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

@media (max-width: 560px) {
  .review-fields {
    grid-template-columns: 1fr;
  }
}

.review-fields .field label {
  font-size: 11.5px;
}

.review-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.review-actions .checkbox-field {
  margin: 0;
  font-weight: 500;
  color: var(--text-muted);
}

.review-buttons {
  display: flex;
  gap: 8px;
  margin-inline-start: auto;
}

.btn-secondary,
.btn-primary {
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1.5px solid var(--border);
  transition: all 0.15s ease;
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
}

.btn-secondary:hover {
  border-color: var(--brand-danger);
  color: var(--brand-danger);
}

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-primary-dark);
}

.review-item.resolved {
  opacity: 0.55;
}

.review-resolved-note {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brand-success);
}

/* ---------- Bulk import ---------- */
.bulk-import-headers {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
}

.bulk-import-headers-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.bulk-import-headers-list {
  font-size: 13px;
  line-height: 1.9;
  color: var(--text-muted);
}

.bulk-import-headers-list code {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

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

.file-picker input[type="file"] {
  flex-shrink: 0;
}

.file-picker-name {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-import-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.bulk-import-stat {
  text-align: center;
  padding: 16px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

.bulk-import-stat-value {
  font-size: 26px;
  font-weight: 800;
}

.bulk-import-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.bulk-import-stat.success .bulk-import-stat-value {
  color: var(--brand-success);
}

.bulk-import-stat.error .bulk-import-stat-value {
  color: var(--brand-danger);
}

.bulk-import-row {
  border: 1.5px solid var(--border);
  border-inline-start: 4px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 10px;
}

.bulk-import-row.success {
  border-inline-start-color: var(--brand-success);
}

.bulk-import-row.exception {
  border-inline-start-color: var(--brand-danger);
}

.bulk-import-row.pending {
  border-inline-start-color: #e6b94f;
}

.bulk-import-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-import-row-number {
  font-weight: 700;
  font-size: 13.5px;
}

.bulk-import-row-orderid {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  color: var(--text-muted);
}

.bulk-import-row-status-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  margin-inline-start: auto;
}

.bulk-import-row-status-badge.success {
  background: var(--brand-success-bg);
  color: var(--brand-success);
}

.bulk-import-row-status-badge.exception {
  background: var(--brand-danger-bg);
  color: var(--brand-danger);
}

.bulk-import-row-status-badge.pending {
  background: #fff6e0;
  color: #9a6d00;
}

[data-theme="dark"] .bulk-import-row-status-badge.pending {
  background: #3a2f10;
  color: #e6b94f;
}

.bulk-import-row-detail {
  margin-top: 6px;
  font-size: 13px;
}

.bulk-import-row-detail .label {
  color: var(--text-muted);
  margin-inline-end: 6px;
}

.bulk-import-row-message {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- Warehouse (mini WMS) ---------- */
.shipment-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  font-size: 13.5px;
}

.shipment-row-id {
  font-weight: 700;
}

.shipment-row-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-primary) 14%, transparent);
  color: var(--brand-primary-dark);
  margin-inline-start: auto;
}

[data-theme="dark"] .shipment-row-status {
  color: var(--brand-accent);
}

.shipment-row-detail {
  color: var(--text-muted);
}

.wand-id-chip {
  display: inline-block;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  background: var(--brand-success-bg);
  color: var(--brand-success);
  border-radius: 999px;
  padding: 3px 10px;
  margin: 3px 6px 3px 0;
}
