/* ═══════════════════════════════════════════════
   ATRAAK OS — styles.css
   Dark luxury / gold theme — RTL Arabic-first
═══════════════════════════════════════════════ */

:root {
  --bg:             #0a0a0a;
  --surface:        #141414;
  --surface-raised: #1c1c1c;
  --surface-high:   #242424;
  --gold:           #C9A84C;
  --gold-light:     #E8C76A;
  --gold-dim:       rgba(201, 168, 76, 0.12);
  --gold-border:    rgba(201, 168, 76, 0.25);
  --text:           #FFFFFF;
  --text-secondary: #9A9A9A;
  --text-muted:     #555555;
  --error:          #FF4D4D;
  --error-bg:       rgba(255, 77, 77, 0.10);
  --success:        #4CAF50;
  --success-bg:     rgba(76, 175, 80, 0.10);
  --border:         rgba(255, 255, 255, 0.07);
  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      16px;
  --radius-xl:      20px;
  --shadow:         0 4px 24px rgba(0,0,0,0.6);
  --shadow-gold:    0 0 20px rgba(201, 168, 76, 0.15);
  --font:           'Cairo', system-ui, sans-serif;
  --safe-bottom:    env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  direction: rtl;
}

/* ── Utility ── */
.screen { min-height: 100dvh; }
[hidden] { display: none !important; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.flex-1 { flex: 1; }

/* ══════════════════════════════════════════════
   SETUP SCREEN
══════════════════════════════════════════════ */
#setup-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  background: radial-gradient(ellipse at 50% 0%, rgba(201,168,76,0.08) 0%, transparent 60%), var(--bg);
}

.setup-inner {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.logo-block {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 48px;
  color: var(--gold);
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(201,168,76,0.4));
}

.logo-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.logo-sub {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}

.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setup-heading {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.setup-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.setup-error {
  font-size: 13px;
  color: var(--error);
  text-align: center;
}

/* ══════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

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

.header-icon {
  font-size: 20px;
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(201,168,76,0.5));
}

.header-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text);
}

.header-settings {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
  line-height: 1;
}
.header-settings:hover { color: var(--gold); }

/* ══════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════ */
.app-main {
  padding: 20px 16px;
  padding-bottom: calc(32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 480px;
  margin: 0 auto;
}

/* ══════════════════════════════════════════════
   UPLOAD ZONE
══════════════════════════════════════════════ */
.upload-zone {
  position: relative;
  width: 100%;
  min-height: 220px;
  border: 2px dashed var(--gold-border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.upload-zone:hover,
.upload-zone:focus {
  border-color: var(--gold);
  background: var(--gold-dim);
  box-shadow: var(--shadow-gold);
  outline: none;
}

.upload-zone:active {
  transform: scale(0.99);
}

.upload-placeholder {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  pointer-events: none;
}

.upload-icon {
  font-size: 52px;
  line-height: 1;
}

.upload-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.upload-hint {
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius-xl) - 2px);
}

.upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 16px;
  border-radius: calc(var(--radius-xl) - 2px);
}

.upload-change-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: rgba(0,0,0,0.7);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
}

/* ══════════════════════════════════════════════
   STATE CARDS (analyzing / saving)
══════════════════════════════════════════════ */
.state-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.state-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.state-hint {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════════
   SPINNER
══════════════════════════════════════════════ */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(201,168,76,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 52px;
  height: 52px;
  border-width: 4px;
}

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

/* ══════════════════════════════════════════════
   RESULT CARD
══════════════════════════════════════════════ */
.result-card {
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-gold);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.result-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.result-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.result-brand {
  font-size: 14px;
  color: var(--gold);
  font-weight: 500;
}

.confidence-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--gold-border);
  white-space: nowrap;
}

.confidence-badge.high   { color: #4CAF50; background: rgba(76,175,80,0.12); border-color: rgba(76,175,80,0.3); }
.confidence-badge.medium { color: var(--gold); background: var(--gold-dim); border-color: var(--gold-border); }
.confidence-badge.low    { color: var(--error); background: var(--error-bg); border-color: rgba(255,77,77,0.3); }

.result-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-width: 80px;
  flex: 1;
}

.meta-key {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meta-val {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.result-notes-block {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.notes-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.notes-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.accords-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.accord-tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--gold-dim);
  color: var(--gold-light);
  border: 1px solid var(--gold-border);
  font-weight: 500;
}

/* ══════════════════════════════════════════════
   FORM CARD
══════════════════════════════════════════════ */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.btn-choice {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 4px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
}

.btn-choice:hover {
  border-color: var(--gold-border);
  color: var(--gold);
  background: var(--gold-dim);
}

.btn-choice.selected {
  background: var(--gold);
  border-color: var(--gold);
  color: #000;
  box-shadow: 0 0 12px rgba(201,168,76,0.35);
}

.btn-choice.btn-custom {
  grid-column: span 2;
  font-size: 12px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

/* ── Field ── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.field-input {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  padding: 12px 14px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  direction: rtl;
  -webkit-appearance: none;
}

.field-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.12);
}

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

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ── Margin display ── */
.margin-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.margin-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.margin-value {
  font-size: 15px;
  color: var(--gold);
  font-weight: 700;
}

.form-error {
  font-size: 13px;
  color: var(--error);
  text-align: center;
  padding: 10px;
  background: var(--error-bg);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,77,77,0.2);
}

/* ══════════════════════════════════════════════
   SUCCESS CARD
══════════════════════════════════════════════ */
.success-card {
  border-color: rgba(76,175,80,0.3) !important;
  background: rgba(76,175,80,0.05) !important;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(76,175,80,0.15);
  border: 2px solid rgba(76,175,80,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--success);
}

.success-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.success-detail {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  padding: 15px 24px;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-user-select: none;
  user-select: none;
  letter-spacing: 0.02em;
  width: fit-content;
}

.btn-primary:hover  { background: var(--gold-light); box-shadow: 0 0 20px rgba(201,168,76,0.3); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.btn-full { width: 100%; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.15s;
  align-self: flex-start;
}
.btn-ghost:hover { border-color: var(--gold-border); color: var(--gold); }

.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ══════════════════════════════════════════════
   ERROR TOAST
══════════════════════════════════════════════ */
.error-toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  max-width: 480px;
  margin: 0 auto;
  background: #1a0808;
  border: 1px solid rgba(255,77,77,0.4);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 1000;
  animation: slideUp 0.25s ease;
}

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

.error-toast-icon { font-size: 16px; flex-shrink: 0; }
.error-toast-msg  { font-size: 13px; color: #FF8A8A; flex: 1; line-height: 1.4; font-weight: 500; }
.error-toast-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer; padding: 2px 4px; flex-shrink: 0;
}
.error-toast-close:hover { color: var(--text); }

/* ══════════════════════════════════════════════
   GLOBAL OVERLAY
══════════════════════════════════════════════ */
.global-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* ══════════════════════════════════════════════
   ANALYZING CARD SPECIAL
══════════════════════════════════════════════ */
.analyzing-card {
  border-color: var(--gold-border);
  background: radial-gradient(ellipse at 50% 0%, rgba(201,168,76,0.05) 0%, transparent 70%), var(--surface);
}

/* ══════════════════════════════════════════════
   HEADER ACTIONS (back + settings)
══════════════════════════════════════════════ */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-back {
  background: none;
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.header-back:hover {
  background: var(--gold-dim);
  color: var(--gold-light);
}

/* ══════════════════════════════════════════════
   HOME SECTION
══════════════════════════════════════════════ */
/* ══════════════════════════════════════════════
   HOME — NAVBAR + HERO
══════════════════════════════════════════════ */

.atraak-navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(10,10,10,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.atraak-navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.atraak-navbar-logo {
  height: 22px;
  width: auto;
  object-fit: contain;
}

.atraak-navbar-brand-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gold);
}

.atraak-navbar-links {
  display: flex;
  align-items: center;
  gap: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.atraak-navbar-links::-webkit-scrollbar { display: none; }

.atraak-navlink {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  position: relative;
  padding-bottom: 5px;
  white-space: nowrap;
}

.atraak-navlink.active {
  color: #fff;
}

.atraak-navlink.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--gold);
}

.atraak-hero {
  position: relative;
  min-height: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 40px 20px;
}

.atraak-hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.atraak-float-card {
  position: absolute;
  width: 72px;
  height: 96px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--gold-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: atraak-drift 24s ease-in-out infinite;
}

.atraak-float-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Position/opacity/blur/timing for each discovered photo are set inline by
   initHeroBrandAssets() in app.js — these two classes only control size. */
.card-lg { width: 72px; height: 96px; }
.card-sm { width: 60px; height: 80px; }

@keyframes atraak-drift {
  0%   { transform: translate(0, 0); }
  50%  { transform: translate(14px, -10px); }
  100% { transform: translate(0, 0); }
}

.atraak-hero-center {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.atraak-hero-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.atraak-hero-logo-fallback {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--gold);
}

.atraak-hero-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
  margin: 0;
}

.atraak-hero-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.atraak-hero-buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.atraak-hero-btn {
  padding: 12px 26px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
}

.atraak-hero-btn-primary {
  background: var(--gold);
  color: #000;
}

.atraak-hero-btn-secondary {
  background: transparent;
  border: 1px solid var(--gold-border);
  color: var(--gold);
}

@media (min-width: 600px) {
  .atraak-hero { min-height: 540px; }
  .atraak-hero-logo { width: 88px; height: 88px; }
  .atraak-hero-title { font-size: 34px; }
  .atraak-float-card { width: 96px; height: 128px; }
}

@media (max-width: 359px) {
  .atraak-hero-title { font-size: 22px; }
  .atraak-navbar-links { gap: 10px; }
  .atraak-navlink { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .atraak-float-card { animation: none; }
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 0 32px;
}

.btn-home {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.1s;
  text-align: right;
}
.btn-home:hover {
  background: var(--gold-dim);
  border-color: var(--gold);
  transform: translateY(-1px);
}
.btn-home:active { transform: translateY(0); }

.btn-home-sale {
  border-color: rgba(201,168,76,0.5);
  background: radial-gradient(ellipse at 100% 0%, rgba(201,168,76,0.08) 0%, transparent 60%), var(--surface);
}

.btn-home-icon {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}
.btn-home-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  font-family: var(--font);
}
.btn-home-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font);
}

/* ══════════════════════════════════════════════
   SALE — SECTION HEADER
══════════════════════════════════════════════ */
.section-header-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 12px;
}

/* ══════════════════════════════════════════════
   SALE — MATCHES LIST
══════════════════════════════════════════════ */
.matches-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
}
.match-card:hover {
  border-color: var(--gold);
  background: var(--gold-dim);
}
.match-card:focus {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.match-card-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.match-card-disabled:hover {
  border-color: var(--border);
  background: var(--surface);
}

.match-info { flex: 1; min-width: 0; }

.match-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.match-brand {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.match-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.match-size, .match-price {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
  padding: 2px 7px;
  border-radius: 20px;
}
.match-price { color: var(--gold); }
.match-qty {
  font-size: 12px;
  color: var(--success, #4CAF50);
}
.match-qty.out-of-stock { color: var(--error, #FF5252); }

.match-arrow {
  font-size: 22px;
  color: var(--gold);
  flex-shrink: 0;
  font-weight: 300;
}

/* ══════════════════════════════════════════════
   SALE — MANUAL SEARCH
══════════════════════════════════════════════ */
.manual-search-trigger {
  text-align: center;
}
.manual-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.manual-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
}

/* ══════════════════════════════════════════════
   SALE — SELECTED ITEM CARD
══════════════════════════════════════════════ */
.sale-selected-card {
  margin-bottom: 0;
}

/* ══════════════════════════════════════════════
   SALE — SUCCESS
══════════════════════════════════════════════ */
.sale-success-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

/* ══════════════════════════════════════════════
   UTILITY
══════════════════════════════════════════════ */
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ══════════════════════════════════════════════
   PURCHASE INVOICE FLOW
══════════════════════════════════════════════ */
.btn-home-purchase {
  border-color: rgba(201,168,76,0.4);
  background: radial-gradient(ellipse at 0% 100%, rgba(201,168,76,0.06) 0%, transparent 60%), var(--surface);
}

.btn-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.pur-size-field {
  width: 104px;
  flex-shrink: 0;
}

.purchase-live-cost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.purchase-live-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.purchase-live-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
}

.purchase-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.purchase-cart-badge {
  background: var(--gold);
  color: #000;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
  min-width: 24px;
  text-align: center;
}

.purchase-cart-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.purchase-cart-item {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.purchase-cart-item-info { flex: 1; min-width: 0; }

.purchase-cart-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.purchase-cart-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.purchase-cart-item-cost {
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
}

.purchase-cart-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.purchase-cart-remove:hover { color: var(--error); background: var(--error-bg); }

.purchase-totals {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.purchase-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.purchase-total-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.purchase-total-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.purchase-total-gold {
  color: var(--gold);
  font-size: 18px;
}

/* ── Purchase invoice header ── */
.purchase-invoice-header {
  padding: 20px 20px 4px;
  text-align: center;
}

.purchase-invoice-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  margin: 0 0 4px;
  letter-spacing: 0.01em;
}

.purchase-supplier-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* ── Supplier/invoice details: collapsed by default (session-first) ── */
.purchase-supplier-panel {
  margin-top: 12px;
}

.purchase-supplier-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.purchase-supplier-fields {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pur-recent-suppliers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pur-supplier-chip {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}

.pur-supplier-chip:active { border-color: var(--gold); color: var(--gold); }

/* ── Cart always-visible ── */
.purchase-cart-card {
  margin-top: 0;
}

.invoice-photo-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.invoice-photos-count {
  font-size: 12px;
  color: var(--text-secondary);
}

.purchase-cart-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 18px 0 10px;
}

/* ── Purchase add-item area ── */
.pur-add-area {
  padding: 0 0 24px;
}

/* ── Picker: camera + manual buttons ── */
.btn-pur-primary {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 22px 16px;
  margin-top: 12px;
  background: rgba(201,168,76,0.1);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font);
  cursor: pointer;
  gap: 4px;
  transition: background 0.18s;
}
.btn-pur-primary:active { background: rgba(201,168,76,0.22); }

.btn-pur-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 16px;
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  gap: 8px;
  transition: border-color 0.18s, color 0.18s;
}
.btn-pur-secondary:active { border-color: var(--gold); color: var(--gold); }

.btn-pur-icon  { font-size: 28px; line-height: 1; }
.btn-pur-label { font-size: 17px; font-weight: 700; }
.btn-pur-hint  { font-size: 12px; color: rgba(201,168,76,0.7); font-weight: 400; }

/* ── State card (analyzing, unknown, no-match) ── */
.pur-state-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 20px 24px;
  margin-top: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.pur-state-warn { border-color: rgba(201,168,76,0.3); }
.pur-state-icon { font-size: 36px; line-height: 1; }
.pur-state-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.pur-state-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}
.pur-state-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}
.pur-state-actions .btn-primary,
.pur-state-actions .btn-ghost { width: 100%; }

/* ── Bottom sheet: item entry states slide up over the cart ── */
.pur-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 600;
}

.pur-bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 601;
  background: var(--surface);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  max-height: 88vh;
  overflow-y: auto;
  padding: 4px 20px calc(20px + var(--safe-bottom));
  animation: pur-sheet-slide-up 0.22s ease-out;
}

@keyframes pur-sheet-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.pur-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 10px auto 14px;
}

.pur-batch-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: fit-content;
  margin: 0 auto 12px;
  padding: 4px 14px;
  border-radius: 20px;
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--gold-border);
  font-size: 13px;
  font-weight: 700;
}

.pur-batch-remaining {
  color: var(--text-secondary);
  font-weight: 400;
}

.pur-batch-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 12px;
}

.pur-batch-controls .btn-ghost {
  width: auto;
  flex: 1;
}

.pur-batch-resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--gold);
}

/* ── Inventory match card ── */
.pur-match-card {
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 12px;
}
.pur-match-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.pur-match-info { flex: 1; min-width: 0; }
.pur-match-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pur-match-brand {
  font-size: 13px;
  color: var(--gold);
  margin-top: 2px;
}
.pur-match-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.pur-match-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pur-match-meta-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pur-match-meta-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ── New item banner ── */
.pur-new-item-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(201,168,76,0.07);
  border: 1px dashed var(--gold-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 12px;
}
.pur-new-item-icon { font-size: 18px; color: var(--gold); }
.pur-new-item-text {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ── Multi-match header ── */
.pur-multi-match-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px 0;
}
.pur-multi-match-header .form-section-label { margin-bottom: 0; }

/* ── Item form header (label + close btn row) ── */
.purchase-item-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.purchase-item-form-header .form-section-label { margin-bottom: 0; }

/* ── Totals margin when below list ── */
.purchase-totals { margin-top: 12px; }

/* ══════════════════════════════════════════════
   SALE SCAN SECTION — mobile-optimized layout
══════════════════════════════════════════════ */
#sale-scan-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* neutralise block margins so gap drives spacing */
#sale-scan-section .mt-12,
#sale-scan-section .mt-8 {
  margin-top: 0;
}

/* shorter upload box — not dominating the screen */
#sale-scan-section .upload-zone {
  min-height: 160px;
}

/* smaller icon so empty state doesn't feel cavernous */
#sale-scan-section .upload-icon {
  font-size: 38px;
}

/* center the "تغيير الصورة" pill inside the preview overlay */
#sale-scan-section .upload-overlay {
  align-items: center;
  justify-content: center;
  padding-bottom: 0;
}

/* ══════════════════════════════════════════════════════════════
   RECEIVING SHIPMENT (استلام شحنة جديدة) — LIGHT / DESKTOP-INSPIRED
   REDESIGN. Entirely scoped under #purchase-items-section (which
   also contains the bottom sheet as a descendant) — no other flow
   (Home, Add Inventory, Sale, Setup) is touched by any rule below.
═══════════════════════════════════════════════════════════════ */
#purchase-items-section {
  --rcv-bg:         #F5F5F5;
  --rcv-card:       #FFFFFF;
  --rcv-border:     #E5E5E5;
  --rcv-text:       #1A1A1A;
  --rcv-text-2:     #6B7280;
  --rcv-text-3:     #9CA3AF;
  --rcv-shadow:     0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.05);
  --rcv-radius:     18px;
  --rcv-radius-sm:  14px;
  --rcv-dark:       #171717;
  --rcv-dark-hover: #2A2A2A;
  --rcv-success:    #16A34A;
  --rcv-success-bg: rgba(22,163,74,0.08);

  background: var(--rcv-bg);
  padding: 24px 16px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Generic white card shell, reused by every step ── */
#purchase-items-section .rcv-card,
#purchase-items-section .form-card,
#purchase-items-section .pur-state-card,
#purchase-items-section .pur-match-card,
#purchase-items-section .purchase-cart-empty {
  background: var(--rcv-card);
  border: 1px solid var(--rcv-border);
  border-radius: var(--rcv-radius);
  box-shadow: var(--rcv-shadow);
  padding: 20px;
}
#purchase-items-section .rcv-card { display: flex; flex-direction: column; gap: 16px; }

#purchase-items-section .rcv-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
/* Supplier card only: the delivery ID ("DEL-YYYYMMDD-HHMMSS-XXXX") is long
   enough to squeeze the title into a wrapped column when shared on one row.
   Stack it as a caption under the title instead — title stays legible at
   any width, ID keeps its own line. Other .rcv-card-header users (e.g. the
   "مدفوعات أخرى" count badge) are short and unaffected by this override. */
#purchase-items-section .rcv-supplier-card .rcv-card-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
#purchase-items-section .rcv-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--rcv-text);
  margin: 0;
}
#purchase-items-section .rcv-delivery-id {
  font-size: 12px;
  color: var(--rcv-text-3);
  margin: 0;
  white-space: nowrap;
}
#purchase-items-section .rcv-divider {
  height: 1px;
  background: var(--rcv-border);
  margin: 4px 0;
}

/* ── STEP 1: supplier toggle + fields ── */
/* padding added for a comfortable tap target — was 0 vertical padding (17px
   total height) despite being the main way to reach the supplier fields. */
#purchase-items-section .purchase-supplier-toggle { color: var(--rcv-text); font-size: 14px; padding: 10px 0; }
#purchase-items-section .purchase-supplier-fields { margin-top: 0; }
#purchase-items-section .field-label,
#purchase-items-section .form-section-label { color: var(--rcv-text-2); }
#purchase-items-section .field-input {
  background: #FAFAFA;
  border: 1px solid var(--rcv-border);
  color: var(--rcv-text);
}
#purchase-items-section .field-input:focus {
  outline: none;
  border-color: var(--rcv-dark);
  background: #fff;
}
#purchase-items-section .form-error {
  background: #FEF2F2;
  border-color: #FCA5A5;
}
#purchase-items-section .pur-supplier-chip {
  background: #FAFAFA;
  border: 1px solid var(--rcv-border);
  color: var(--rcv-text-2);
}
#purchase-items-section .pur-supplier-chip:active { border-color: var(--rcv-dark); color: var(--rcv-dark); }

/* ── Choice buttons (qty / currency) ── */
#purchase-items-section .btn-choice {
  background: #FAFAFA;
  border: 1px solid var(--rcv-border);
  color: var(--rcv-text-2);
}
#purchase-items-section .btn-choice.selected {
  background: var(--rcv-dark);
  border-color: var(--rcv-dark);
  color: #fff;
  box-shadow: none;
}

/* ── Buttons: dark neutral everywhere except the final confirm button ── */
#purchase-items-section .btn-primary { background: var(--rcv-dark); color: #fff; }
#purchase-items-section .btn-primary:active { background: var(--rcv-dark-hover); }
#purchase-items-section .btn-ghost {
  background: #fff;
  border: 1px solid var(--rcv-border);
  color: var(--rcv-text-2);
}
#purchase-items-section .btn-ghost:hover { border-color: var(--rcv-text-3); color: var(--rcv-text); }

/* Final action button — the ONLY gold element in this entire flow */
#purchase-items-section #purchase-confirm-btn.btn-primary { background: var(--gold); color: #000; }
#purchase-items-section #purchase-confirm-btn.btn-primary:active { background: var(--gold-light); }
#purchase-items-section #purchase-confirm-btn:disabled {
  background: #E5E5E5;
  color: #9CA3AF;
  cursor: not-allowed;
}

/* ── Batch resume banner / progress / controls ── */
#purchase-items-section .pur-batch-resume-banner {
  background: #FAFAFA;
  border: 1px solid var(--rcv-border);
  color: var(--rcv-text);
}
#purchase-items-section .pur-batch-progress {
  background: #F0F0F0;
  border: 1px solid var(--rcv-border);
  color: var(--rcv-text);
}
#purchase-items-section .pur-batch-remaining { color: var(--rcv-text-2); }

/* ══ STEP 2 — Product Entry Workspace: 2x2 grid of white cards ══ */
#purchase-items-section .rcv-workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
#purchase-items-section .rcv-workspace-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  background: #FAFAFA;
  border: 1px solid var(--rcv-border);
  border-radius: var(--rcv-radius-sm);
  padding: 18px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  text-align: right;
}
#purchase-items-section .rcv-workspace-btn:active {
  background: #F0F0F0;
  border-color: var(--rcv-text-3);
  transform: scale(0.98);
}
#purchase-items-section .rcv-workspace-icon { font-size: 26px; line-height: 1; }
#purchase-items-section .rcv-workspace-title { font-size: 14px; font-weight: 700; color: var(--rcv-text); }
#purchase-items-section .rcv-workspace-desc { font-size: 11px; color: var(--rcv-text-2); font-weight: 400; line-height: 1.4; }
#purchase-items-section .rcv-workspace-btn-wide { grid-column: span 2; }

/* ── "More options" disclosure — reuses .btn-ghost/.btn-sm, just adds layout ── */
#purchase-items-section .pur-more-options-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}
#purchase-items-section #pur-more-options { margin-top: 12px; }

/* ── Top action buttons (invoice photo / open product selector) ── */
#purchase-items-section .rcv-top-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
#purchase-items-section .rcv-top-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  border-radius: var(--rcv-radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
}
#purchase-items-section .rcv-top-action-icon { font-size: 16px; line-height: 1; }
#purchase-items-section .rcv-top-action-blue  { background: #2563EB; }
#purchase-items-section .rcv-top-action-blue:active  { background: #1D4ED8; }
/* Lighter tint (not a solid fill) — "add invoice photo" is a secondary/
   optional action, so it reads calmer than the primary "add product" button
   instead of competing with it at equal visual weight. */
#purchase-items-section .rcv-top-action-green {
  background: var(--rcv-success-bg);
  color: var(--rcv-success);
  border: 1px solid rgba(22,163,74,0.25);
}
#purchase-items-section .rcv-top-action-green:active { background: rgba(22,163,74,0.16); }

/* ══ STEP 3 — Detected Products ══ */
#purchase-items-section .rcv-products-section { display: flex; flex-direction: column; gap: 12px; }
#purchase-items-section .rcv-products-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}
#purchase-items-section .purchase-cart-badge { background: var(--rcv-dark); color: #fff; }
#purchase-items-section .purchase-cart-list { gap: 12px; }
#purchase-items-section .purchase-cart-empty {
  text-align: center;
  color: var(--rcv-text-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#purchase-items-section .purchase-cart-empty-icon { font-size: 28px; opacity: 0.4; }

/* .purchase-cart-item's base rule (shared with nothing outside this screen)
   is dark-themed by default — override to the light card system used
   everywhere else in Receiving Shipment. */
#purchase-items-section .purchase-cart-item {
  background: var(--rcv-card);
  border: 1px solid var(--rcv-border);
  border-radius: var(--rcv-radius-sm);
}
#purchase-items-section .rcv-product-card { align-items: flex-start; padding: 14px; gap: 12px; }
#purchase-items-section .rcv-product-thumb {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  overflow: hidden;
  background: #F0F0F0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#purchase-items-section .rcv-product-thumb img { width: 100%; height: 100%; object-fit: cover; }
#purchase-items-section .rcv-product-thumb-fallback { font-size: 22px; }
#purchase-items-section .purchase-cart-item-name { color: var(--rcv-text); }
#purchase-items-section .purchase-cart-item-meta { color: var(--rcv-text-2); }
#purchase-items-section .rcv-product-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--rcv-text-2);
  margin-top: 4px;
}
#purchase-items-section .rcv-profit-positive { color: var(--rcv-success); font-weight: 700; }
#purchase-items-section .rcv-profit-negative { color: var(--error); font-weight: 700; }
/* padding added for a comfortable tap target — was ~24x23px (icon-only). */
#purchase-items-section .purchase-cart-remove { color: var(--rcv-text-3); padding: 10px 12px; }
#purchase-items-section .purchase-cart-remove:hover { color: var(--error); background: #FEF2F2; }

/* ══ STEP 4 — Summary ══ */
#purchase-items-section .rcv-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#purchase-items-section .rcv-summary-label { font-size: 13px; color: var(--rcv-text-2); }
#purchase-items-section .rcv-summary-value { font-size: 15px; font-weight: 700; color: var(--rcv-text); }
#purchase-items-section .rcv-summary-highlight .rcv-summary-value { font-size: 18px; }

/* ══ STEP 5 — Final Confirmation (always last) ══ */
#purchase-items-section .rcv-final-section { display: flex; flex-direction: column; gap: 10px; }
#purchase-items-section .rcv-confirm-btn {
  padding: 18px;
  font-size: 16px;
  border-radius: var(--rcv-radius-sm);
  box-shadow: 0 4px 14px rgba(201,168,76,0.3);
}

/* ── Live cost / margin displays (green, not gold) ── */
#purchase-items-section .purchase-live-cost { background: #FAFAFA; border: 1px solid var(--rcv-border); }
#purchase-items-section .purchase-live-label { color: var(--rcv-text-2); }
#purchase-items-section .purchase-live-value { color: var(--rcv-text); }
#purchase-items-section .margin-display {
  background: var(--rcv-success-bg);
  border: 1px solid rgba(22,163,74,0.25);
}
#purchase-items-section .margin-label { color: var(--rcv-text-2); }

/* ── Match cards (multi-match / manual search) ── */
/* Base .match-card is dark-themed by default — only :hover/:focus had a light
   override before, so the resting state still rendered as a dark card. */
#purchase-items-section .match-card {
  background: var(--rcv-card);
  border: 1px solid var(--rcv-border);
  border-radius: var(--rcv-radius-sm);
}
#purchase-items-section .match-card:hover { border-color: var(--rcv-text-3); background: #FAFAFA; }
#purchase-items-section .match-card:focus { outline: 2px solid var(--rcv-dark); }
#purchase-items-section .match-name { color: var(--rcv-text); }
#purchase-items-section .match-brand { color: var(--rcv-text-2); }
#purchase-items-section .match-size,
#purchase-items-section .match-price { background: #F0F0F0; color: var(--rcv-text-2); }
#purchase-items-section .match-price { color: var(--rcv-text); font-weight: 700; }
#purchase-items-section .match-arrow { color: var(--rcv-text-3); }

/* ── Inventory match card (existing item, bottom sheet entry state) ── */
#purchase-items-section .pur-match-card { border-color: var(--rcv-border); }
#purchase-items-section .pur-match-name { color: var(--rcv-text); }
#purchase-items-section .pur-match-brand { color: var(--rcv-text-2); }
#purchase-items-section .pur-match-meta-label { color: var(--rcv-text-3); }
#purchase-items-section .pur-match-meta-val { color: var(--rcv-text); }

#purchase-items-section .pur-new-item-banner { background: #FAFAFA; border: 1px dashed var(--rcv-text-3); }
#purchase-items-section .pur-new-item-icon { color: var(--rcv-dark); }
#purchase-items-section .pur-new-item-text { color: var(--rcv-text); }

#purchase-items-section .pur-state-title { color: var(--rcv-text); }
#purchase-items-section .pur-state-sub { color: var(--rcv-text-2); }
#purchase-items-section .pur-state-warn { border-color: var(--rcv-border); }

#purchase-items-section .spinner {
  border: 3px solid rgba(23,23,23,0.1);
  border-top-color: var(--rcv-dark);
}

/* ── Bottom sheet: white surface instead of dark ── */
#purchase-items-section .pur-bottom-sheet { background: var(--rcv-card); }
#purchase-items-section .pur-sheet-handle { background: var(--rcv-border); }

@media (max-width: 359px) {
  #purchase-items-section .rcv-workspace-grid { gap: 8px; }
  #purchase-items-section .rcv-workspace-btn { padding: 14px 12px; }
}

/* ── Manual product entry ── */
#purchase-items-section .rcv-card-subtitle {
  font-size: 12px;
  color: var(--rcv-text-2);
  margin: -8px 0 0;
}

/* ── "يدوي" badge on manually-entered product cards ── */
#purchase-items-section .rcv-manual-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--rcv-text-2);
  background: #F0F0F0;
  border-radius: 8px;
  padding: 1px 7px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ── Other payments ── */
#purchase-items-section .rcv-field-hint {
  font-size: 11px;
  color: var(--rcv-text-3);
  margin: -4px 0 0;
}
#purchase-items-section .rcv-other-payments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#purchase-items-section .rcv-other-payment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FAFAFA;
  border: 1px solid var(--rcv-border);
  border-radius: var(--rcv-radius-sm);
  padding: 10px 12px;
}
#purchase-items-section .rcv-other-payment-info { flex: 1; min-width: 0; }
#purchase-items-section .rcv-other-payment-type {
  font-size: 13px;
  font-weight: 600;
  color: var(--rcv-text);
}
#purchase-items-section .rcv-other-payment-note {
  font-size: 11px;
  color: var(--rcv-text-2);
  margin-top: 2px;
}
#purchase-items-section .rcv-other-payment-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--rcv-text);
  white-space: nowrap;
}
/* padding bumped for a comfortable tap target (was 4px/6px, ~icon-only size) */
#purchase-items-section .rcv-other-payment-remove {
  background: none;
  border: none;
  color: var(--rcv-text-3);
  font-size: 15px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: var(--rcv-radius-sm);
  flex-shrink: 0;
  line-height: 1;
}
#purchase-items-section .rcv-other-payment-remove:hover { color: var(--error); background: #FEF2F2; }

/* ── Calmer state transitions inside the bottom sheet — same easing family as
   the existing sheet slide-up animation, just extended to the state swaps
   inside it (analyzing → entry → etc.) and the "more options" reveal. Purely
   decorative: app.js still just toggles the [hidden] attribute exactly as
   before. ── */
#purchase-items-section .pur-state:not([hidden]),
#purchase-items-section #pur-more-options:not([hidden]) {
  animation: pur-fade-in 0.18s ease-out;
}
@keyframes pur-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   PURCHASE SUBMITTING / SUCCESS — same light theme as the rest of
   Receiving Shipment. These two sections sit as siblings of
   #purchase-items-section (not descendants), so the light tokens don't
   cascade down automatically — redeclared here, scoped to these two IDs
   only. Sale/Inventory's own submitting/success sections are untouched.
═══════════════════════════════════════════════════════════════ */
#purchase-submitting-section,
#purchase-success-section {
  --rcv-bg:      #F5F5F5;
  --rcv-card:    #FFFFFF;
  --rcv-border:  #E5E5E5;
  --rcv-text:    #1A1A1A;
  --rcv-text-2:  #6B7280;
  --rcv-shadow:  0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.05);
  --rcv-dark:       #171717;
  --rcv-dark-hover: #2A2A2A;
  --rcv-success:    #16A34A;
  background: var(--rcv-bg);
  padding: 24px 16px calc(24px + var(--safe-bottom));
}
#purchase-submitting-section .state-card,
#purchase-success-section .success-card {
  background: var(--rcv-card);
  border: 1px solid var(--rcv-border);
  box-shadow: var(--rcv-shadow);
}
#purchase-success-section .success-card {
  border-color: rgba(22,163,74,0.25) !important;
  background: rgba(22,163,74,0.05) !important;
}
#purchase-submitting-section .state-label,
#purchase-success-section .success-name { color: var(--rcv-text); }
#purchase-submitting-section .state-hint,
#purchase-success-section .success-detail { color: var(--rcv-text-2); }
#purchase-submitting-section .spinner { border-color: rgba(23,23,23,0.1); border-top-color: var(--rcv-dark); }
#purchase-success-section .success-icon {
  background: rgba(22,163,74,0.12);
  border-color: rgba(22,163,74,0.35);
  color: var(--rcv-success);
}
#purchase-success-section .btn-primary { background: var(--rcv-dark); color: #fff; }
#purchase-success-section .btn-primary:active { background: var(--rcv-dark-hover); }
#purchase-success-section .btn-ghost { background: #fff; border: 1px solid var(--rcv-border); color: var(--rcv-text-2); }
#purchase-success-section .btn-ghost:hover { border-color: #9CA3AF; color: var(--rcv-text); }

/* ── "رجوع" button: floating bottom-right, Receiving Shipment screen only.
   Same element/click-handler/.header-back styling as on every other
   screen — app.js's relocateBackButton() moves this exact node to be a
   direct child of #app-screen only while the Receiving Shipment screen is
   active (necessary because .app-header's backdrop-filter creates a new
   containing block, which would otherwise anchor a fixed button to the
   header instead of the real viewport). This selector only matches while
   it's in that relocated position; everywhere else it stays inside
   .header-actions and this rule has no effect. ── */
#app-screen > #back-btn {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  margin: 0;
  z-index: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

/* Hide it while the add-item bottom sheet is open so it doesn't float over
   the sheet, which already occupies the bottom of the screen. */
body:has(#pur-bottom-sheet:not([hidden])) #app-screen > #back-btn {
  display: none;
}
