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

/* Ensure [hidden] always wins over display rules like flex/grid */
[hidden] { display: none !important; }

:root {
  --indigo:      #4F46E5;
  --indigo-lt:   #EEF2FF;
  --indigo-mid:  #C7D2FE;
  --indigo-dk:   #3730A3;
  --green:       #059669;
  --green-lt:    #D1FAE5;
  --amber:       #D97706;
  --amber-lt:    #FEF3C7;
  --red:         #DC2626;
  --red-lt:      #FEE2E2;
  --gray-50:     #F9FAFB;
  --gray-100:    #F3F4F6;
  --gray-200:    #E5E7EB;
  --gray-300:    #D1D5DB;
  --gray-400:    #9CA3AF;
  --gray-500:    #6B7280;
  --gray-600:    #4B5563;
  --gray-700:    #374151;
  --gray-900:    #111827;

  /* Card/panel surfaces (was literal white/#fff throughout) */
  --surface:     #FFFFFF;
  /* Text drawn on top of an accent-colored button */
  --on-accent:   #FFFFFF;

  /* Indigo-tinted focus rings & glows */
  --ring-1:         rgba(79,70,229,.1);
  --ring-2:         rgba(79,70,229,.12);
  --ring-3:         rgba(79,70,229,.08);
  --brand-shadow-1: rgba(79,70,229,.3);
  --brand-shadow-2: rgba(79,70,229,.4);

  /* Error bar / toast borders */
  --red-border:  #FECACA;

  /* Format badges (xlsx / csv) */
  --blue-lt:     #DBEAFE;
  --blue:        #1D4ED8;
  --green-dk:    #065F46;

  /* "Already listed" box */
  --sky-lt:      #EFF6FF;
  --sky-border:  #BFDBFE;
  --sky:         #0369A1;

  /* "Pack SKUs" box + pack badge */
  --violet-lt:        #F5F3FF;
  --violet-border:    #DDD6FE;
  --violet:           #6D28D9;
  --violet-badge-bg:  #F3E8FF;
  --violet-accent:    #7C3AED;

  /* Warning box border */
  --amber-border: #FDE68A;

  /* Recommendations table row tint */
  --green-wash:  #F0FDF4;

  /* Toasts */
  --toast-success-bg:     #DCFCE7;
  --toast-success-fg:     #166534;
  --toast-success-border: #BBF7D0;
  --toast-error-fg:       #991B1B;

  /* Login screen brand gradient — intentionally NOT redefined in dark mode;
     the login screen keeps its fixed branded look regardless of OS theme. */
  --login-grad-1: #3730A3;
  --login-grad-2: #4F46E5;
  --login-grad-3: #6366F1;

  --radius:      12px;
  --radius-sm:   8px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Dark mode — OS-driven by default, with a manual override ───────
   Redefines the same custom properties above with a dark palette.
   The login screen (.login-body) is reset back to the light palette
   right below, matching the convention used by the other KG Apps Hub
   tools — the rest of the app goes dark, sign-in stays put.

   A manual toggle (see app.js) sets data-theme="dark"/"light" on
   <html> to override the OS setting; :not([data-theme="light"]) lets
   an explicit light choice suppress the dark media query, and the
   :root[data-theme="dark"] block below applies dark regardless of OS
   when the user explicitly chose it. ────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --indigo:      #818CF8;
    --indigo-lt:   #1E1B4B;
    --indigo-mid:  #3730A3;
    --indigo-dk:   #A5B4FC;
    --green:       #34D399;
    --green-lt:    #113828;
    --amber:       #FBBF24;
    --amber-lt:    #3A2E0E;
    --red:         #F87171;
    --red-lt:      #3B1518;
    --gray-50:     #12161D;
    --gray-100:    #1B212B;
    --gray-200:    #2A323D;
    --gray-300:    #3A4451;
    --gray-400:    #7C8797;
    --gray-500:    #94A0AF;
    --gray-600:    #B0BAC7;
    --gray-700:    #C7CFD9;
    --gray-900:    #F1F4F8;

    --surface:     #1B212B;
    --on-accent:   #FFFFFF;

    --ring-1:         rgba(129,140,248,.22);
    --ring-2:         rgba(129,140,248,.28);
    --ring-3:         rgba(129,140,248,.2);
    --brand-shadow-1: rgba(129,140,248,.35);
    --brand-shadow-2: rgba(129,140,248,.45);

    --red-border:  #7F1D1D;

    --blue-lt:     #16233D;
    --blue:        #93C5FD;
    --green-dk:    #6EE7B7;

    --sky-lt:      #0F2436;
    --sky-border:  #1E3A54;
    --sky:         #7DD3FC;

    --violet-lt:        #241B3D;
    --violet-border:    #4C3575;
    --violet:           #C4B5FD;
    --violet-badge-bg:  #2C1F4A;
    --violet-accent:    #D8B4FE;

    --amber-border: #78350F;

    --green-wash:  #10241A;

    --toast-success-bg:     #113322;
    --toast-success-fg:     #86EFAC;
    --toast-success-border: #14532D;
    --toast-error-fg:       #FCA5A5;
  }

  /* Sign-in screen: stays on its fixed light/branded look in dark mode too,
     the same way the other KG Apps Hub tools keep their login screen put. */
  .login-body {
    --indigo:      #4F46E5;
    --indigo-lt:   #EEF2FF;
    --indigo-mid:  #C7D2FE;
    --indigo-dk:   #3730A3;
    --red:         #DC2626;
    --red-lt:      #FEE2E2;
    --gray-50:     #F9FAFB;
    --gray-100:    #F3F4F6;
    --gray-200:    #E5E7EB;
    --gray-300:    #D1D5DB;
    --gray-400:    #9CA3AF;
    --gray-500:    #6B7280;
    --gray-600:    #4B5563;
    --gray-700:    #374151;
    --gray-900:    #111827;
    --surface:     #FFFFFF;
    --ring-1:      rgba(79,70,229,.1);
    --ring-2:      rgba(79,70,229,.12);
  }
}

/* Explicit override so the manual toggle works regardless of the OS setting */
:root[data-theme="dark"] {
  --indigo:      #818CF8;
  --indigo-lt:   #1E1B4B;
  --indigo-mid:  #3730A3;
  --indigo-dk:   #A5B4FC;
  --green:       #34D399;
  --green-lt:    #113828;
  --amber:       #FBBF24;
  --amber-lt:    #3A2E0E;
  --red:         #F87171;
  --red-lt:      #3B1518;
  --gray-50:     #12161D;
  --gray-100:    #1B212B;
  --gray-200:    #2A323D;
  --gray-300:    #3A4451;
  --gray-400:    #7C8797;
  --gray-500:    #94A0AF;
  --gray-600:    #B0BAC7;
  --gray-700:    #C7CFD9;
  --gray-900:    #F1F4F8;

  --surface:     #1B212B;
  --on-accent:   #FFFFFF;

  --ring-1:         rgba(129,140,248,.22);
  --ring-2:         rgba(129,140,248,.28);
  --ring-3:         rgba(129,140,248,.2);
  --brand-shadow-1: rgba(129,140,248,.35);
  --brand-shadow-2: rgba(129,140,248,.45);

  --red-border:  #7F1D1D;

  --blue-lt:     #16233D;
  --blue:        #93C5FD;
  --green-dk:    #6EE7B7;

  --sky-lt:      #0F2436;
  --sky-border:  #1E3A54;
  --sky:         #7DD3FC;

  --violet-lt:        #241B3D;
  --violet-border:    #4C3575;
  --violet:           #C4B5FD;
  --violet-badge-bg:  #2C1F4A;
  --violet-accent:    #D8B4FE;

  --amber-border: #78350F;

  --green-wash:  #10241A;

  --toast-success-bg:     #113322;
  --toast-success-fg:     #86EFAC;
  --toast-success-border: #14532D;
  --toast-error-fg:       #FCA5A5;
}
html[data-theme="dark"] body.login-body {
  --indigo:      #4F46E5;
  --indigo-lt:   #EEF2FF;
  --indigo-mid:  #C7D2FE;
  --indigo-dk:   #3730A3;
  --red:         #DC2626;
  --red-lt:      #FEE2E2;
  --gray-50:     #F9FAFB;
  --gray-100:    #F3F4F6;
  --gray-200:    #E5E7EB;
  --gray-300:    #D1D5DB;
  --gray-400:    #9CA3AF;
  --gray-500:    #6B7280;
  --gray-600:    #4B5563;
  --gray-700:    #374151;
  --gray-900:    #111827;
  --surface:     #FFFFFF;
  --ring-1:      rgba(79,70,229,.1);
  --ring-2:      rgba(79,70,229,.12);
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 9px; }
.logo-text { font-weight: 700; font-size: .97rem; color: var(--gray-900); letter-spacing: -.01em; }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 4px; }
.bc-step {
  font-size: .82rem;
  font-weight: 500;
  color: var(--gray-400);
  padding: 3px 8px;
  border-radius: 6px;
  transition: color .2s, background .2s;
}
.bc-step.bc-active { color: var(--indigo); background: var(--indigo-lt); }
.bc-arrow { flex-shrink: 0; }

/* ── Page wrapper & view transitions ────────────────────────────── */
.page-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 40px 24px 56px;
  transition: transform .38s cubic-bezier(.4,0,.2,1), opacity .38s ease;
  will-change: transform, opacity;
  transform: translateX(0);
  opacity: 1;
}
.view-hidden  { transform: translateX(100%); opacity: 0; pointer-events: none; }
.view-exit-left { transform: translateX(-60px); opacity: 0; pointer-events: none; }
.view-enter   { transform: translateX(0) !important; opacity: 1 !important; pointer-events: auto !important; }

.view-inner { max-width: 640px; margin: 0 auto; }

/* ── Page title block ────────────────────────────────────────────── */
.page-title-block { margin-bottom: 28px; }
.page-title { font-size: 1.45rem; font-weight: 800; color: var(--gray-900); letter-spacing: -.025em; line-height: 1.2; }
.page-sub { margin-top: 8px; font-size: .88rem; color: var(--gray-500); line-height: 1.6; }

/* ── SKU textarea ────────────────────────────────────────────────── */
.sku-block {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.sku-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sku-label {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-500);
}
.sku-count {
  font-size: .78rem;
  font-weight: 600;
  color: var(--gray-400);
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--gray-100);
  transition: color .15s, background .15s;
}
.sku-count.has-skus { color: var(--indigo); background: var(--indigo-lt); }

.sku-textarea {
  width: 100%;
  resize: vertical;
  min-height: 100px;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: .83rem;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.6;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.sku-textarea::placeholder { color: var(--gray-400); font-family: var(--font); font-size: .83rem; }
.sku-textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--ring-1);
  background: var(--surface);
}
.sku-hint { margin-top: 7px; font-size: .75rem; color: var(--gray-400); }

/* ── Searchable client dropdown ──────────────────────────────────── */
.search-select-wrap {
  position: relative;          /* anchor for the dropdown */
  display: flex;
  align-items: center;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  padding: 0 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  cursor: text;
}
.search-select-wrap:focus-within,
.search-select-wrap.search-open {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--ring-1);
  background: var(--surface);
}
.search-select-wrap.tenant-selected {
  border-color: var(--indigo-mid);
  background: var(--surface);
}
.search-select-wrap.tenant-error {
  border-color: var(--red);
  background: var(--red-lt);
}
.search-select-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font);
  font-size: .88rem;
  color: var(--gray-900);
  padding: 10px 0;
  cursor: text;
}
.search-select-input::placeholder { color: var(--gray-400); }

/* Clear (×) button */
.search-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  flex-shrink: 0;
  border: none;
  background: var(--gray-200);
  border-radius: 50%;
  color: var(--gray-500);
  cursor: pointer;
  padding: 0;
  margin-left: 6px;
  transition: background .15s, color .15s;
}
.search-clear-btn:hover { background: var(--gray-300); color: var(--gray-800); }

/* Chevron rotation when open */
.search-select-wrap .tenant-chevron { transition: transform .2s ease; flex-shrink: 0; }
.search-select-wrap.search-open .tenant-chevron { transform: rotate(180deg); }

/* Dropdown list */
.search-select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: -2px;
  right: -2px;
  background: var(--surface);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.05);
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  list-style: none;
  padding: 4px;
  scroll-behavior: smooth;
}
.search-select-item {
  padding: 9px 12px;
  font-size: .88rem;
  color: var(--gray-700);
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s, color .1s;
  user-select: none;
}
.search-select-item:hover,
.search-select-item.highlighted {
  background: var(--indigo-lt);
  color: var(--indigo);
  font-weight: 500;
}
.search-no-results {
  padding: 10px 12px;
  font-size: .83rem;
  color: var(--gray-400);
  font-style: italic;
  list-style: none;
}

/* ── Tenant selector ─────────────────────────────────────────────── */
.tenant-block {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.tenant-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.tenant-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  padding: 0 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.tenant-select-wrap:focus-within {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--ring-1);
  background: var(--surface);
}
.tenant-select-wrap.tenant-selected {
  border-color: var(--indigo-mid);
  background: var(--surface);
}
.tenant-select-wrap.tenant-error {
  border-color: var(--red);
  background: var(--red-lt);
}
.tenant-icon {
  flex-shrink: 0;
  color: var(--gray-400);
  pointer-events: none;
  margin-right: 8px;
}
.tenant-select {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font);
  font-size: .88rem;
  color: var(--gray-700);
  padding: 10px 0;
  cursor: pointer;
  min-width: 0;
}
.tenant-select:focus { outline: none; }
.tenant-select:disabled { color: var(--gray-400); cursor: not-allowed; }
.tenant-select-wrap.tenant-select-disabled {
  opacity: 0.55;
  background: var(--gray-100);
  pointer-events: none;
}
/* Searchable dropdown — disabled state (tenant not yet unlocked) */
.search-select-wrap.search-select-disabled {
  opacity: 0.55;
  background: var(--gray-100);
  cursor: not-allowed;
}
.search-select-wrap.search-select-disabled .search-select-input {
  cursor: not-allowed;
}
.search-select-wrap.search-select-disabled .tenant-chevron {
  pointer-events: none;
}
.tenant-chevron {
  flex-shrink: 0;
  color: var(--gray-400);
  pointer-events: none;
  margin-left: 8px;
}
.tenant-badge {
  font-size: .75rem;
  font-weight: 600;
  color: var(--indigo);
  background: var(--indigo-lt);
  padding: 2px 9px;
  border-radius: 20px;
  border: 1px solid var(--indigo-mid);
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.result-tenant-badge {
  display: inline-block;
  margin-top: 5px;
  margin-right: 4px;
  font-size: .74rem;
  font-weight: 600;
  color: var(--indigo);
  background: var(--indigo-lt);
  padding: 2px 9px;
  border-radius: 20px;
  border: 1px solid var(--indigo-mid);
  white-space: nowrap;
}

/* ── Search mode tabs ────────────────────────────────────────────── */
.search-mode-tabs {
  display: flex;
  gap: 3px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
}
.mode-tab {
  flex: 1;
  padding: 6px 8px;
  font-size: .77rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--gray-500);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.mode-tab:hover:not(.mode-tab-active) {
  color: var(--gray-700);
  background: rgba(0,0,0,.05);
}
.mode-tab.mode-tab-active {
  background: var(--surface);
  color: var(--indigo);
  box-shadow: 0 1px 3px rgba(0,0,0,.1), 0 0 0 1px var(--ring-3);
}

/* Search panels & fields */
.search-panel { }
.search-field { margin-top: 12px; }
.search-field:first-child { margin-top: 0; }
.search-field > .sku-label { display: block; margin-bottom: 6px; }

/* Generic single-line text input (supplier / brand) */
.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .88rem;
  color: var(--gray-900);
  background: var(--gray-50);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.text-input::placeholder { color: var(--gray-400); }
.text-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--ring-1);
  background: var(--surface);
}

/* ── Options row ─────────────────────────────────────────────────── */
.options-row { margin-bottom: 20px; }
.save-toggle {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
}
.save-toggle input { display: none; }
.toggle-track {
  width: 36px; height: 20px;
  background: var(--gray-300); border-radius: 10px;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.save-toggle input:checked ~ .toggle-track { background: var(--indigo); }
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--surface); border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.save-toggle input:checked ~ .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-text { font-size: .84rem; color: var(--gray-600); }
.toggle-text code {
  background: var(--gray-100); padding: 1px 5px; border-radius: 4px;
  font-size: .85em; color: var(--gray-700);
}

/* ── Error bar ───────────────────────────────────────────────────── */
.error-bar {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--red-lt); border: 1px solid var(--red-border);
  border-radius: var(--radius-sm); padding: 11px 14px;
  margin-bottom: 20px;
  font-size: .84rem; color: var(--red); line-height: 1.5;
}

/* ── Marketplace button section ──────────────────────────────────── */
.mp-btn-section { }
.section-label {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--gray-400);
  margin-bottom: 12px;
}

.mp-btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.mp-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, box-shadow .15s, background .15s, transform .1s;
  color: var(--gray-900);
}
.mp-btn:hover:not(:disabled) {
  border-color: var(--indigo);
  box-shadow: 0 2px 10px var(--ring-2);
  background: var(--indigo-lt);
  transform: translateY(-1px);
}
.mp-btn:active:not(:disabled) { transform: translateY(0); }
.mp-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.mp-btn-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.mp-btn-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-btn-fmt {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 2px 6px;
  border-radius: 4px;
  width: fit-content;
}
.mp-btn-fmt.xlsx { background: var(--blue-lt); color: var(--blue); }
.mp-btn-fmt.csv  { background: var(--green-lt); color: var(--green-dk); }

.mp-btn-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--gray-100);
  color: var(--gray-500);
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.mp-btn:hover:not(:disabled) .mp-btn-arrow {
  background: var(--indigo);
  color: var(--on-accent);
}
.mp-btn:disabled .mp-btn-arrow { opacity: .5; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin-icon { animation: spin .75s linear infinite; }

/* ── Results view ────────────────────────────────────────────────── */
.success-banner {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.success-icon { flex-shrink: 0; }
.success-text { flex: 1; min-width: 0; }
.success-title { font-size: 1rem; font-weight: 700; color: var(--gray-900); }
.success-sub { font-size: .83rem; color: var(--gray-500); margin-top: 2px; }

.download-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 20px;
  background: var(--indigo); color: var(--on-accent);
  border: none; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s;
  box-shadow: 0 2px 8px var(--brand-shadow-1);
  margin-left: auto;
}
.download-btn:hover { background: var(--indigo-dk); box-shadow: 0 4px 14px var(--brand-shadow-2); }

/* Marketplace cards (results grid) */
.mp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.mp-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.mp-card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 12px;
}
.mp-name { font-size: .88rem; font-weight: 700; color: var(--gray-900); line-height: 1.3; }
.mp-fmt {
  font-size: .65rem; font-weight: 700; letter-spacing: .06em;
  padding: 2px 6px; border-radius: 4px; flex-shrink: 0; margin-top: 1px;
}
.mp-fmt.xlsx { background: var(--blue-lt); color: var(--blue); }
.mp-fmt.csv  { background: var(--green-lt); color: var(--green-dk); }
.mp-stats { display: flex; flex-direction: column; gap: 6px; }
.mp-stat-row { display: flex; justify-content: space-between; align-items: center; }
.mp-stat-label { font-size: .77rem; color: var(--gray-400); }
.mp-stat-val { font-size: .82rem; font-weight: 600; color: var(--gray-700); }
.mp-stat-val.file { color: var(--indigo); font-size: .75rem; word-break: break-all; }
.mp-status {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 5px;
  font-size: .76rem; font-weight: 600;
}
.mp-status.ok { color: var(--green); }
.mp-status.warn { color: var(--amber); }

/* Already-listed box */
.listed-box {
  background: var(--sky-lt);
  border: 1px solid var(--sky-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.listed-box-title {
  display: flex; align-items: center; gap: 6px;
  font-size: .84rem; font-weight: 700; color: var(--sky); margin-bottom: 8px;
}
.listed-sku {
  font-weight: 700;
  color: var(--sky);
  min-width: 90px;
}

/* Pack SKUs box */
.pack-box {
  background: var(--violet-lt);
  border: 1px solid var(--violet-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.pack-box-title {
  display: flex; align-items: center; gap: 6px;
  font-size: .84rem; font-weight: 700; color: var(--violet); margin-bottom: 8px;
}
.pack-sku {
  font-weight: 700;
  color: var(--violet);
  min-width: 90px;
}

/* Warning box */
.warn-box {
  background: var(--amber-lt); border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 24px;
}
.warn-box-title {
  display: flex; align-items: center; gap: 6px;
  font-size: .84rem; font-weight: 700; color: var(--amber); margin-bottom: 8px;
}
.warn-list { list-style: none; }
.warn-list li {
  display: flex; gap: 8px;
  font-size: .82rem; color: var(--gray-700); padding: 3px 0;
}
.warn-sku { font-weight: 700; color: var(--amber); min-width: 90px; }

/* Back button */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: .84rem; font-weight: 500; color: var(--gray-500);
  cursor: pointer;
  transition: all .15s;
}
.back-btn:hover { border-color: var(--indigo-mid); color: var(--indigo); background: var(--indigo-lt); }

/* ══════════════════════════════════════════════════════════════════
   RECOMMENDATIONS PAGE
══════════════════════════════════════════════════════════════════ */

/* Header wider variant for the table page */
.header-inner-wide { max-width: 1100px; }

/* App-level navigation pills */
.app-nav { display: flex; align-items: center; gap: 3px; }
.app-nav-link {
  font-size: .8rem; font-weight: 500; color: var(--gray-500);
  text-decoration: none; padding: 5px 10px;
  border-radius: 6px; transition: color .15s, background .15s;
  white-space: nowrap;
}
.app-nav-link:hover { color: var(--gray-900); background: var(--gray-100); }
.app-nav-active { color: var(--indigo) !important; background: var(--indigo-lt) !important; }

/* Page layout */
.rec-page { flex: 1; padding: 40px 24px 140px; }
.rec-page-inner { max-width: 1100px; margin: 0 auto; }
.rec-filter-section { max-width: 640px; }

/* Two-column optional-filter row */
.rec-opt-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; margin-bottom: 18px;
}
.rec-opt-tag {
  font-size: .7rem; font-weight: 400; color: var(--gray-400);
  text-transform: none; letter-spacing: 0; margin-left: 5px;
}

/* Load Products button */
.load-products-btn {
  width: 100%; padding: 11px 20px;
  background: var(--indigo); color: var(--on-accent);
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .9rem; font-weight: 600;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px;
  transition: background .15s, opacity .15s;
}
.load-products-btn:hover:not(:disabled) { background: var(--indigo-dk); }
.load-products-btn:disabled { opacity: .45; cursor: not-allowed; }
.load-spin {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: var(--on-accent);
  border-radius: 50%; animation: rec-spin .65s linear infinite;
}
@keyframes rec-spin { to { transform: rotate(360deg); } }

/* Results header strip */
.rec-results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 28px 0 12px; flex-wrap: wrap; gap: 8px;
}
.rec-results-title {
  font-size: .95rem; font-weight: 700; color: var(--gray-900);
  display: flex; align-items: baseline; gap: 8px;
}
.rec-results-sub { font-size: .78rem; font-weight: 400; color: var(--gray-500); }
.rec-results-actions { display: flex; gap: 8px; }
.btn-ghost-sm {
  padding: 5px 12px; font-size: .78rem; font-weight: 500;
  color: var(--gray-600); background: var(--surface);
  border: 1px solid var(--gray-200); border-radius: 6px;
  cursor: pointer; font-family: var(--font);
  transition: background .12s, border-color .12s;
}
.btn-ghost-sm:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--gray-900); }

/* Table wrapper */
.rec-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--surface);
}

/* The table itself */
.rec-table { width: 100%; border-collapse: collapse; font-size: .84rem; }

/* Header */
.rec-table thead tr { border-bottom: 2px solid var(--gray-200); background: var(--gray-50); }

.rec-th-product {
  text-align: left; padding: 11px 16px;
  font-size: .72rem; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .07em;
  min-width: 260px;
  position: sticky; left: 0; background: var(--gray-50); z-index: 3;
  box-shadow: 2px 0 0 0 var(--gray-200);
  white-space: nowrap;
}

.rec-th-mp {
  text-align: center; padding: 8px 6px;
  width: 90px; min-width: 90px; vertical-align: top;
  border-left: 1px solid var(--gray-200);
}
.rec-mp-th-inner { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.rec-mp-th-name {
  font-size: .72rem; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap;
}
.rec-sel-col-btn {
  font-size: .69rem; font-weight: 600;
  color: var(--indigo); background: var(--indigo-lt);
  border: 1px solid var(--indigo-mid); border-radius: 4px;
  padding: 2px 7px; cursor: pointer; font-family: var(--font);
  white-space: nowrap; text-transform: none; letter-spacing: 0;
  transition: background .12s;
}
.rec-sel-col-btn:hover { background: var(--indigo-mid); }
.rec-sel-col-btn.col-all-sel { background: var(--indigo); color: var(--on-accent); border-color: var(--indigo); }

/* Body rows */
.rec-table tbody tr { border-bottom: 1px solid var(--gray-100); transition: background .08s; }
.rec-table tbody tr:last-child { border-bottom: none; }
.rec-table tbody tr:hover { background: var(--indigo-lt); }
.rec-table tbody tr:hover .rec-td-product { background: var(--indigo-lt); }

/* Product cell — sticky */
.rec-td-product {
  position: sticky; left: 0; background: var(--surface); z-index: 1;
  box-shadow: 2px 0 0 0 var(--gray-100);
  padding: 10px 16px;
}
.rec-product-cell { display: flex; align-items: center; gap: 10px; }
.rec-img-wrap {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 6px; overflow: hidden;
  background: var(--gray-100); border: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center;
}
.rec-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rec-img-placeholder { color: var(--gray-300); }
.rec-product-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rec-product-name {
  font-size: .84rem; font-weight: 600; color: var(--gray-900);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 185px;
}
.rec-product-sku {
  font-size: .72rem; color: var(--gray-500);
  font-family: 'SF Mono', ui-monospace, monospace;
}
.rec-product-brand { font-size: .71rem; color: var(--indigo); font-weight: 500; }
.rec-pack-badge {
  display: inline-flex; align-items: center; font-size: .67rem; font-weight: 600;
  background: var(--violet-badge-bg); color: var(--violet-accent); border: 1px solid var(--violet-border);
  padding: 1px 7px; border-radius: 20px; margin-top: 2px; width: fit-content;
}

/* Marketplace cells */
.rec-td-mp {
  text-align: center; vertical-align: middle; padding: 8px 4px;
  border-left: 1px solid var(--gray-100);
}
.rec-td-listed  { background: var(--green-wash); }
.rec-td-pack    { background: var(--gray-50); }

/* Listed green tick */
.rec-listed-check { display: inline-flex; }

/* Unlisted checkbox */
.rec-checkbox {
  width: 17px; height: 17px; cursor: pointer;
  accent-color: var(--indigo); vertical-align: middle;
}

/* Pack dash */
.rec-pack-dash { color: var(--gray-300); font-size: 1rem; line-height: 1; }

/* Loading / empty states inside results */
.rec-loading, .rec-empty {
  text-align: center; padding: 52px 24px; color: var(--gray-500); font-size: .88rem;
}
.rec-loading-spin {
  width: 30px; height: 30px; margin: 0 auto 14px;
  border: 3px solid var(--gray-200); border-top-color: var(--indigo);
  border-radius: 50%; animation: rec-spin .65s linear infinite;
}
.rec-empty-icon { font-size: 2rem; margin-bottom: 10px; }
.rec-empty-title { font-size: .95rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }

/* Sticky generate bar */
.rec-gen-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-top: 1px solid var(--gray-200);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,.09);
}
.rec-gen-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.rec-gen-count { font-size: .9rem; font-weight: 700; color: var(--gray-900); white-space: nowrap; }
.rec-gen-breakdown { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rec-gen-chip {
  font-size: .75rem; font-weight: 500;
  background: var(--indigo-lt); color: var(--indigo);
  border: 1px solid var(--indigo-mid);
  padding: 2px 9px; border-radius: 20px; white-space: nowrap;
}
.rec-gen-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.rec-gen-clear {
  padding: 8px 16px; font-size: .84rem; font-weight: 500;
  color: var(--gray-600); background: var(--surface);
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  cursor: pointer; font-family: var(--font);
  transition: background .12s;
}
.rec-gen-clear:hover { background: var(--gray-100); }
.rec-gen-submit {
  padding: 8px 18px; font-size: .88rem; font-weight: 600;
  color: var(--on-accent); background: var(--indigo); border: none;
  border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font);
  display: flex; align-items: center; gap: 7px;
  transition: background .12s;
}
.rec-gen-submit:hover:not(:disabled) { background: var(--indigo-dk); }
.rec-gen-submit:disabled { opacity: .55; cursor: not-allowed; }

/* Responsive */
@media (max-width: 640px) {
  .rec-opt-row { grid-template-columns: 1fr; }
  .rec-gen-breakdown { display: none; }
}

/* ── Email delivery option (generate page) ────────────────────────── */
.email-option {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 18px;
}
.email-opt-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.email-opt-icon { flex-shrink: 0; color: var(--indigo); }
.email-opt-body { flex: 1; min-width: 0; }
.email-opt-body .sku-label { display: block; margin-bottom: 7px; }
.email-text-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .88rem;
  color: var(--gray-900);
  background: var(--gray-50);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.email-text-input::placeholder { color: var(--gray-400); }
.email-text-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--ring-1);
  background: var(--surface);
}

/* Preview link shown in dev mode */
.email-preview-link {
  display: inline-block;
  margin-top: 6px;
  font-size: .78rem;
  color: var(--indigo);
  text-decoration: underline;
}
.email-preview-link:hover { color: var(--indigo-dk); }

/* Email-sent success icon (replaces green check in banner) */
.success-icon-mail { background: var(--indigo-lt); border-radius: 50%; padding: 3px; }

/* Email input inside the recommendations generate bar */
.rec-gen-email {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  max-width: 280px;
  min-width: 0;
  color: var(--gray-400);
}
.rec-gen-email-input {
  flex: 1; min-width: 0;
  padding: 7px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .84rem;
  color: var(--gray-900); background: var(--gray-50);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.rec-gen-email-input::placeholder { color: var(--gray-400); }
.rec-gen-email-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--ring-1);
  background: var(--surface);
}

/* Toast notification */
.toast {
  position: fixed; top: 70px; right: 20px; z-index: 9999;
  padding: 12px 18px; border-radius: 9px;
  font-family: var(--font); font-size: .86rem; font-weight: 500;
  max-width: 360px; pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  transform: translateY(-8px); opacity: 0;
  transition: transform .28s cubic-bezier(.2,.8,.4,1), opacity .28s ease;
}
.toast.toast-visible { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--toast-success-bg); color: var(--toast-success-fg); border: 1px solid var(--toast-success-border); }
.toast-error   { background: var(--red-lt); color: var(--toast-error-fg); border: 1px solid var(--red-border); }
.toast-info    { background: var(--indigo-lt); color: var(--indigo); border: 1px solid var(--indigo-mid); }

/* ── Footer ──────────────────────────────────────────────────────── */
.footer {
  text-align: center; font-size: .76rem; color: var(--gray-400);
  padding: 18px 24px; border-top: 1px solid var(--gray-200);
  background: var(--surface);
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .view { padding: 24px 16px 48px; }
  .mp-btn-grid { grid-template-columns: 1fr; }
  .success-banner { padding: 16px; flex-direction: column; align-items: flex-start; }
  .download-btn { width: 100%; justify-content: center; margin-left: 0; }
  .mp-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════════ */

/* Override body background for login only */
.login-body {
  background: linear-gradient(145deg, var(--login-grad-1) 0%, var(--login-grad-2) 60%, var(--login-grad-3) 100%);
  min-height: 100vh;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0,0,0,.22), 0 4px 16px rgba(0,0,0,.12);
  width: 100%;
  max-width: 400px;
  padding: 40px 36px 36px;
}

/* Brand row */
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-brand-name { font-size: 1.03rem; font-weight: 700; color: var(--gray-900); }

/* Headings */
.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gray-900);
  text-align: center;
  margin-bottom: 6px;
}
.login-sub {
  font-size: .875rem;
  color: var(--gray-500);
  text-align: center;
  margin-bottom: 22px;
}

/* Fields */
.login-field { margin-bottom: 16px; }
.login-field .sku-label { display: block; margin-bottom: 6px; }

.login-input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--ring-2);
}

/* Password with eye toggle */
.login-pw-wrap { position: relative; }
.login-pw-wrap .login-input { padding-right: 44px; }

.login-eye-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color .15s;
}
.login-eye-btn:hover { color: var(--gray-600); }

/* Forgot-password link row */
.login-forgot-row {
  text-align: right;
  margin-top: -6px;
  margin-bottom: 20px;
}
.login-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: .85rem;
  font-family: var(--font);
  color: var(--indigo);
  cursor: pointer;
}
.login-link-btn:hover { text-decoration: underline; }

/* Submit button */
.login-submit {
  width: 100%;
  padding: 11px;
  background: var(--indigo);
  color: var(--on-accent);
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, transform .1s;
}
.login-submit:hover:not(:disabled) { background: var(--indigo-dk); }
.login-submit:active:not(:disabled) { transform: scale(.99); }
.login-submit:disabled { opacity: .7; cursor: not-allowed; }

/* Spinner inside sign-in button */
.login-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: var(--on-accent);
  border-radius: 50%;
  animation: rec-spin .7s linear infinite;
  flex-shrink: 0;
}

/* Forgot-password view */
.forgot-icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  margin-top: 8px;
}

/* ── Nav logout button ───────────────────────────────────────────── */
.app-nav-logout {
  background: none;
  border: 1.5px solid var(--gray-200);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: .8rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: border-color .15s, color .15s, background .15s;
  margin-left: 4px;
  white-space: nowrap;
}
.app-nav-logout:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-lt);
}

.theme-toggle-btn {
  background: none;
  border: 1.5px solid var(--gray-200);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: .9rem;
  line-height: 1;
  font-family: var(--font);
  cursor: pointer;
  color: var(--gray-500);
  transition: border-color .15s, background .15s;
  margin-left: 4px;
}
.theme-toggle-btn:hover { background: var(--gray-100); }

@media (max-width: 480px) {
  .login-card { padding: 28px 20px 24px; }
}
