/* ─────────────────────────────────────────────────────────────────────────
   Apple HIG Design System — Parts Portal
   SF Pro · System Colors · 8pt Grid · 44pt Touch Targets · Light/Dark Mode
   ───────────────────────────────────────────────────────────────────────── */

/* ── CSS Custom Properties ─────────────────────────────────────────────── */
:root {
  /* Typography — SF Pro system stack */
  --font-system: -apple-system, BlinkMacSystemFont, 'SF Pro Display',
                 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:   'SF Mono', SFMono-Regular, Menlo, Monaco, monospace;

  /* Type scale */
  --text-caption2: 11px;
  --text-caption1: 12px;
  --text-footnote: 13px;
  --text-subhead:  15px;
  --text-body:     17px;
  --text-headline: 17px;
  --text-title3:   20px;
  --text-title2:   22px;
  --text-title1:   28px;

  /* System Colors — Light */
  --system-blue:   #007AFF;
  --system-green:  #34C759;
  --system-orange: #FF9500;
  --system-red:    #FF3B30;
  --system-yellow: #FFCC00;
  --system-indigo: #5856D6;
  --system-gray:   #8E8E93;
  --system-gray2:  #AEAEB2;
  --system-gray3:  #C7C7CC;
  --system-gray4:  #D1D1D6;
  --system-gray5:  #E5E5EA;
  --system-gray6:  #F2F2F7;

  /* Semantic labels */
  --label-primary:    #000000;
  --label-secondary:  rgba(60, 60, 67, 0.6);
  --label-tertiary:   rgba(60, 60, 67, 0.3);
  --label-quaternary: rgba(60, 60, 67, 0.18);

  /* Backgrounds */
  --bg-primary:   #FFFFFF;
  --bg-secondary: #F2F2F7;
  --bg-tertiary:  #FFFFFF;

  /* Fills */
  --fill-primary:   rgba(120, 120, 128, 0.2);
  --fill-secondary: rgba(120, 120, 128, 0.16);

  /* Separators */
  --separator:        rgba(60, 60, 67, 0.29);
  --separator-opaque: #C6C6C8;

  /* Spacing — 8pt grid */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Border radius — concentric */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* Animation */
  --ease-default:  cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out:      cubic-bezier(0, 0, 0.58, 1);
  --ease-spring:   cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --duration-fast:   200ms;
  --duration-normal: 300ms;

  /* Nav heights */
  --nav-height:     52px;
  --tab-bar-height: 83px; /* 49px + safe-area */
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --system-blue:   #0A84FF;
    --system-green:  #30D158;
    --system-orange: #FF9F0A;
    --system-red:    #FF453A;
    --system-yellow: #FFD60A;
    --system-indigo: #5E5CE6;
    --system-gray:   #8E8E93;
    --system-gray2:  #636366;
    --system-gray3:  #48484A;
    --system-gray4:  #3A3A3C;
    --system-gray5:  #2C2C2E;
    --system-gray6:  #1C1C1E;

    --label-primary:    #FFFFFF;
    --label-secondary:  rgba(235, 235, 245, 0.6);
    --label-tertiary:   rgba(235, 235, 245, 0.3);
    --label-quaternary: rgba(235, 235, 245, 0.18);

    --bg-primary:   #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary:  #2C2C2E;

    --fill-primary:   rgba(120, 120, 128, 0.36);
    --fill-secondary: rgba(120, 120, 128, 0.28);

    --separator:        rgba(84, 84, 88, 0.6);
    --separator-opaque: #38383A;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-system);
  font-size: var(--text-body);
  background: var(--bg-secondary);
  color: var(--label-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
code {
  font-family: var(--font-mono);
  font-size: var(--text-footnote);
  background: var(--fill-secondary);
  color: var(--label-primary);
  padding: 2px 6px;
  border-radius: 5px;
}
small { font-size: var(--text-caption1); color: var(--label-secondary); }

/* ── Navigation Bar (Toolbar) ───────────────────────────────────────────── */
.header {
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--separator);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  height: var(--nav-height);
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

/* Leading — Logo */
.logo {
  font-size: var(--text-headline);
  font-weight: 700;
  color: var(--label-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.logo span { color: var(--system-blue); }

/* Center — Nav links */
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 44px;
  padding: 0 var(--space-3);
  font-size: var(--text-subhead);
  font-weight: 500;
  color: var(--label-secondary);
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) var(--ease-default),
              background var(--duration-fast) var(--ease-default);
  white-space: nowrap;
}
.nav-link:hover  { color: var(--label-primary); background: var(--fill-secondary); }
.nav-link.active { color: var(--system-blue); font-weight: 600; }

/* Trailing — User info + logout */
.header-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.user-name {
  font-size: var(--text-subhead);
  color: var(--label-secondary);
  white-space: nowrap;
}
.logout-btn {
  min-height: 32px;
  padding: 6px var(--space-3);
  font-size: var(--text-footnote);
  font-weight: 500;
  color: var(--system-blue);
  background: rgba(0, 122, 255, 0.1);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default);
  font-family: var(--font-system);
  white-space: nowrap;
}
.logout-btn:hover { background: rgba(0, 122, 255, 0.18); }

/* Logo image — nav bar */
.logo-img {
  height: 28px;
  width: auto;
  display: block;
  mix-blend-mode: multiply;   /* drops the white background on light bg */
}
@media (prefers-color-scheme: dark) {
  .logo-img { mix-blend-mode: normal; filter: invert(1); }
}

/* Cart badge */
.cart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--system-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  line-height: 1;
}

/* ── Mobile Tab Bar ─────────────────────────────────────────────────────── */
.mobile-menu-btn { display: none; }
.mobile-nav      { display: none; }

.tab-bar {
  display: none;
  justify-content: space-around;
  align-items: flex-start;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tab-bar-height);
  padding-top: var(--space-2);
  padding-bottom: env(safe-area-inset-bottom, 16px);
  background: var(--bg-primary);
  border-top: 0.5px solid var(--separator);
  z-index: 90;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-1) var(--space-2);
  color: var(--system-gray);
  font-family: var(--font-system);
  gap: 2px;
}
.tab-item--active { color: var(--system-blue); }

.tab-item__icon  { font-size: 22px; line-height: 1; }
.tab-item__label { font-size: 10px; font-weight: 500; white-space: nowrap; }

.tab-item__badge {
  position: absolute;
  top: 0;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--system-red);
  border-radius: 8px;
  text-align: center;
  line-height: 16px;
}

/* ── Flash Messages ─────────────────────────────────────────────────────── */
.flash-wrap {
  max-width: 1100px;
  margin: var(--space-4) auto 0;
  padding: 0 var(--space-4);
}
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-subhead);
  margin-bottom: var(--space-2);
  background: rgba(0, 122, 255, 0.1);
  color: var(--system-blue);
  border: 0.5px solid rgba(0, 122, 255, 0.3);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: var(--space-4) var(--space-4);
  font-size: var(--text-caption1);
  color: var(--label-tertiary);
  border-top: 0.5px solid var(--separator);
  background: var(--bg-primary);
  margin-top: auto;
}

/* ── Main Content ───────────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-12);
  width: 100%;
}

/* ── Page Header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-3);
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: var(--text-title1);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--label-primary);
}

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-subhead);
  color: var(--system-blue);
  margin-bottom: var(--space-2);
  font-weight: 500;
}
.back-link:hover { opacity: 0.8; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-6);
  font-family: var(--font-system);
  font-size: var(--text-headline);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--system-blue);
  color: #FFFFFF;
}
.btn-primary:hover { opacity: 0.88; }

.btn-secondary {
  background: rgba(0, 122, 255, 0.1);
  color: var(--system-blue);
}
.btn-secondary:hover { background: rgba(0, 122, 255, 0.16); }

.btn-danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--system-red);
}
.btn-danger:hover { background: rgba(255, 59, 48, 0.2); }

/* Small button — keep min-height but reduce padding */
.btn-sm {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-subhead);
  font-weight: 500;
}

.btn-full { width: 100%; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-6);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.04),
    0 4px 16px rgba(0, 0, 0, 0.06);
}

/* ── Brand Grid ─────────────────────────────────────────────────────────── */
.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
}

.brand-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  text-align: center;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.04),
    0 4px 16px rgba(0, 0, 0, 0.06);
  transition: transform var(--duration-fast) var(--ease-spring),
              box-shadow var(--duration-fast) var(--ease-default);
  -webkit-tap-highlight-color: transparent;
}
.brand-card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.04),
    0 12px 28px rgba(0, 0, 0, 0.1);
}
.brand-card:active { transform: scale(0.97); }

.brand-card h3 {
  font-size: var(--text-headline);
  font-weight: 600;
  color: var(--label-primary);
  margin-bottom: var(--space-2);
}
.brand-icon {
  font-size: 2rem;
  font-weight: 700;
  color: var(--system-blue);
  margin-bottom: var(--space-3);
}
.brand-icon--img {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  margin-bottom: var(--space-3);
}
.brand-icon--img img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.discount-tag {
  display: inline-block;
  background: rgba(0, 122, 255, 0.12);
  color: var(--system-blue);
  font-size: var(--text-caption1);
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* ── Tables — HIG Grouped List Style ───────────────────────────────────── */
.table-wrap {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.parts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-subhead);
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.parts-table thead tr {
  background: var(--bg-secondary);
}

.parts-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-subhead);
  font-weight: 700;
  color: var(--label-primary);
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--separator);
  white-space: nowrap;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}
.sort-link:hover { color: var(--system-blue); }
.sort-th--active .sort-link { color: var(--system-blue); }

.parts-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 0.5px solid var(--separator);
  color: var(--label-primary);
  vertical-align: middle;
}

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

.parts-table tbody tr {
  transition: background var(--duration-fast) var(--ease-default);
}
.parts-table tbody tr:hover td { background: var(--fill-secondary); }

.price-cell  { font-weight: 600; white-space: nowrap; }
.desc-cell   { color: var(--label-secondary); max-width: 240px; font-size: var(--text-footnote); }

.low-stock-row td { background: rgba(255, 149, 0, 0.07) !important; }

/* Info table (order detail) */
.info-table { width: 100%; border-collapse: collapse; font-size: var(--text-subhead); }
.info-table td {
  padding: var(--space-2) var(--space-1);
  border-bottom: 0.5px solid var(--separator);
  vertical-align: top;
}
.info-table tr:last-child td { border-bottom: none; }
.info-table td:first-child {
  color: var(--label-secondary);
  width: 76px;
  font-size: var(--text-footnote);
  padding-right: var(--space-3);
  white-space: nowrap;
}

/* Empty states */
.empty-text {
  text-align: center;
  color: var(--label-tertiary);
  padding: var(--space-10) 0;
  font-size: var(--text-subhead);
}
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--label-secondary);
}
.empty-state p { font-size: var(--text-body); margin-bottom: var(--space-4); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-caption1);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-green  { background: rgba(52, 199, 89, 0.15);   color: #1a7a3c; }
.badge-red    { background: rgba(255, 59, 48, 0.13);   color: #c0392b; }
.badge-yellow { background: rgba(255, 204, 0, 0.2);    color: #7a5800; }
.badge-blue   { background: rgba(0, 122, 255, 0.12);   color: var(--system-blue); }
.badge-gray   { background: var(--fill-secondary);     color: var(--label-secondary); }
.badge-orange { background: rgba(255, 149, 0, 0.15);   color: #c05f00; }

@media (prefers-color-scheme: dark) {
  .badge-green  { background: rgba(48, 209, 88, 0.2);  color: #30d158; }
  .badge-red    { background: rgba(255, 69, 58, 0.2);  color: #ff453a; }
  .badge-yellow { background: rgba(255, 214, 10, 0.2); color: #ffd60a; }
  .badge-blue   { background: rgba(10, 132, 255, 0.2); color: var(--system-blue); }
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.field label {
  font-size: var(--text-footnote);
  font-weight: 600;
  color: var(--label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* HIG input — filled, no border, focus ring */
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="tel"],
.field textarea,
.select-input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-4);
  font-family: var(--font-system);
  font-size: var(--text-body);
  color: var(--label-primary);
  background: var(--bg-secondary);
  border: none;
  border-radius: var(--radius-md);
  outline: none;
  transition: box-shadow var(--duration-fast) var(--ease-default);
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { padding: var(--space-3) var(--space-4); min-height: 80px; resize: vertical; }

.field input:focus,
.field textarea:focus,
.select-input:focus {
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.3);
}
.field input::placeholder { color: var(--label-tertiary); }
.field input:disabled,
.select-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qty-input {
  width: 64px;
  min-height: 36px;
  padding: 0 var(--space-2);
  font-family: var(--font-system);
  font-size: var(--text-subhead);
  color: var(--label-primary);
  background: var(--bg-secondary);
  border: none;
  border-radius: var(--radius-sm);
  text-align: center;
  outline: none;
}
.qty-input:focus { box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.3); }

.discount-input {
  width: 80px;
  min-height: 36px;
  padding: 0 var(--space-2);
  font-family: var(--font-system);
  font-size: var(--text-subhead);
  color: var(--label-primary);
  background: var(--bg-secondary);
  border: none;
  border-radius: var(--radius-sm);
  text-align: right;
  outline: none;
}
.discount-input:focus { box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.3); }
.discount-input:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Modals / Sheets ────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  align-items: flex-end;  /* slide up from bottom on mobile */
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .modal { align-items: center; padding: var(--space-5); }
}

.modal-card {
  background: var(--bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-2) var(--space-5) var(--space-6);
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.15);
  animation: slideUp var(--duration-normal) var(--ease-out) forwards;
}

@media (min-width: 640px) {
  .modal-card {
    border-radius: var(--radius-2xl);
    max-width: 480px;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.2);
    animation: scaleIn var(--duration-normal) var(--ease-spring) forwards;
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes scaleIn {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* Grabber indicator */
.modal-card::before {
  content: '';
  display: block;
  width: 36px;
  height: 5px;
  background: var(--label-quaternary);
  border-radius: 2.5px;
  margin: var(--space-2) auto var(--space-5);
}
@media (min-width: 640px) {
  .modal-card::before { display: none; }
}

.modal-card h2 {
  font-size: var(--text-title3);
  font-weight: 700;
  color: var(--label-primary);
  margin-bottom: var(--space-5);
  letter-spacing: -0.01em;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-4);
  border-top: 0.5px solid var(--separator);
}

/* ── Stats Grid ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.stat-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-5);
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.stat-card.stat-warn {
  background: rgba(255, 149, 0, 0.1);
  box-shadow: none;
}

.stat-num {
  font-size: 36px;
  font-weight: 800;
  color: var(--label-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat-warn .stat-num { color: var(--system-orange); }

.stat-label {
  font-size: var(--text-footnote);
  color: var(--label-secondary);
  font-weight: 500;
}

/* ── Order Detail Layout ────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-5);
  align-items: start;
}

.summary-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-5);
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
}
.summary-card .total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-3);
  border-top: 0.5px solid var(--separator);
  margin-top: var(--space-3);
  font-size: var(--text-headline);
  font-weight: 700;
}

.status-form {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.status-form .select-input { flex: 1; min-width: 120px; width: auto; }

.status-select-wrap {
  position: relative;
  flex: 1;
  min-width: 120px;
}
.status-select-wrap .select-input {
  width: 100%;
  padding-right: 36px;
}
.status-select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  display: flex;
  align-items: center;
  transition: color var(--duration-fast) var(--ease-default);
}

/* ── Cart Layout ────────────────────────────────────────────────────────── */
.cart-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-5);
  align-items: start;
}

/* ── Add-to-cart form ───────────────────────────────────────────────────── */
.add-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Out-of-stock ───────────────────────────────────────────────────────── */
.out-of-stock { opacity: 0.45; pointer-events: none; }

/* ── Brand Access (user_access.html) ────────────────────────────────────── */
.access-row td { transition: background var(--duration-fast) var(--ease-default); }
.access-enabled td { background: rgba(52, 199, 89, 0.07) !important; }

/* ── Dashboard logo ─────────────────────────────────────────────────────── */
.dashboard-logo {
  height: 48px;
  width: auto;
  display: block;
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  .dashboard-logo { mix-blend-mode: normal; filter: invert(1); }
}

/* ── Login Page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  padding: var(--space-5);
}

.login-wrap { width: 100%; max-width: 390px; }

.login-card {
  background: var(--bg-primary);
  border-radius: var(--radius-2xl);
  padding: var(--space-8) var(--space-6) var(--space-6);
  box-shadow:
    0 1px 0 rgba(0,0,0,.04),
    0 20px 60px rgba(0,0,0,.12);
}

/* Login logo — inside the card */
.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-3);
}
.login-logo-img {
  height: 36px;
  width: auto;
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  .login-logo-img { mix-blend-mode: normal; filter: invert(1); }
}

.login-title {
  font-size: calc(var(--text-body) * 2);
  font-weight: 700;
  color: var(--label-primary);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-1);
  text-align: center;
}
.login-title span { color: var(--system-blue); }

.login-sub {
  font-size: var(--text-subhead);
  color: var(--label-secondary);
  margin-bottom: var(--space-6);
  text-align: center;
}

.login-card .flash {
  margin-bottom: var(--space-4);
  background: rgba(255, 59, 48, 0.1);
  color: var(--system-red);
  border-color: rgba(255, 59, 48, 0.3);
}

/* ── Filter Bar (parts page) ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.filter-search {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.filter-search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}
.filter-search-input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-8) 0 36px;
  font-family: var(--font-system);
  font-size: var(--text-subhead);
  color: var(--label-primary);
  background: var(--bg-tertiary);
  border: none;
  border-radius: var(--radius-full);
  outline: none;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.06);
  transition: box-shadow var(--duration-fast) var(--ease-default);
}
.filter-search-input:focus {
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.25),
              0 2px 8px rgba(0,0,0,.06);
}
.filter-search-input::placeholder { color: var(--label-tertiary); }
.filter-clear-btn {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  background: var(--fill-primary);
  border: none;
  border-radius: var(--radius-full);
  width: 20px;
  height: 20px;
  font-size: 11px;
  cursor: pointer;
  color: var(--label-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-select {
  min-height: 44px;
  width: auto;
  min-width: 120px;
  padding: 0 var(--space-4);
  background: var(--bg-tertiary);
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.06);
  border-radius: var(--radius-full);
}

.filter-count {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-footnote);
  color: var(--label-secondary);
}
.filter-active-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: rgba(0, 122, 255, 0.12);
  color: var(--system-blue);
  border-radius: var(--radius-full);
  font-size: var(--text-caption1);
  font-weight: 600;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  /* Hide desktop nav, show tab bar */
  .nav          { display: none; }
  .header-user  { display: none; }
  .tab-bar      { display: flex; }

  /* Add bottom padding so content clears tab bar */
  .main { padding-bottom: calc(var(--tab-bar-height) + var(--space-8)); }

  /* Stack page headers */
  .page-header { flex-direction: column; align-items: flex-start; }

  /* Full-width layouts */
  .detail-grid  { grid-template-columns: 1fr; }
  .cart-layout  { grid-template-columns: 1fr; }
  .stats-grid   { grid-template-columns: 1fr 1fr; }
  .brand-grid   { grid-template-columns: 1fr 1fr; }

  /* Large title scales down */
  .page-header h1 { font-size: var(--text-title2); }
}

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

/* ── Delete / remove button ─────────────────────────────────────────────── */
.del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--fill-primary);
  color: var(--system-red);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default);
}
.del-btn:hover { background: rgba(255, 59, 48, 0.15); }

/* ── Bulk action bar ────────────────────────────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: var(--text-footnote);
  color: var(--label-secondary);
}

/* ── Tech message thread ────────────────────────────────────────────────── */
.tech-msg { padding: var(--space-4); }
.tech-msg--outgoing { border-left: 3px solid var(--system-blue); }
.tech-msg--incoming { border-left: 3px solid #34c759; }
.tech-msg__header { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.tech-msg__body { display: flex; flex-direction: column; gap: var(--space-3); }
.tech-msg__block { background: var(--bg-secondary); border-radius: var(--radius-md); padding: var(--space-3); }
.tech-msg__block--translated { background: var(--fill-primary); }
.tech-msg__lang { font-size: var(--text-footnote); font-weight: 600; color: var(--label-secondary); margin-bottom: var(--space-2); }
.tech-msg__text { margin: 0; white-space: pre-wrap; font-size: var(--text-subhead); line-height: 1.6; }
.tech-msg__divider { text-align: center; color: var(--label-tertiary); font-size: var(--text-footnote); }

/* ── Tech attachments ───────────────────────────────────────────────────── */
.tech-msg__attachments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--separator);
}
.tech-attach--img {
  display: block;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--separator);
}
.tech-attach--img img {
  display: block;
  max-height: 160px;
  max-width: 240px;
  object-fit: cover;
}
.tech-attach--file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--fill-primary);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  font-size: var(--text-footnote);
  color: var(--system-blue);
  text-decoration: none;
}
.tech-attach--file:hover { background: var(--fill-secondary); }
