/* ── Parts Inventory page ───────────────────────────────────────────────────────── */

.header-left { display: flex; align-items: center; gap: 16px; min-width: 0; }

.parts-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 16px 3rem;
}

.parts-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  padding: 16px;
}

.parts-message { text-align: center; color: #b91c1c; font-weight: 500; padding: 2rem; }

/* Tabs */
.parts-tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.parts-tab {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 0.875rem;
  font-weight: 600;
}
.parts-tab:hover { background: rgba(255,255,255,0.25); }
.parts-tab.active { background: #fff; color: #1f2937; border-color: #fff; }
.parts-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 9px;
  background: #f59e0b;
  color: #fff;
  font-size: 0.72rem;
  line-height: 18px;
  text-align: center;
}

/* Toolbar */
.parts-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.parts-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.parts-add-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.parts-add-form input, .parts-add-form select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 0.875rem;
  font-family: inherit;
  min-width: 0;
}
.parts-add-form input[name="sku"], .parts-add-form select { width: 200px; }
.parts-add-form input[name="name"] { width: 240px; }
.parts-narrow { width: 90px; }
.parts-asin { width: 120px; }
.parts-url-input { width: 220px; }

.parts-btn {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #1f2937;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.parts-btn:hover { background: #f3f4f6; }
.parts-btn:disabled { opacity: 0.5; cursor: default; }
.parts-btn-primary { background: #2266dd; border-color: #2266dd; color: #fff; }
.parts-btn-primary:hover { background: #1d4ed8; }

.parts-link-btn {
  background: none;
  border: none;
  color: #2266dd;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0;
}
.parts-link-btn:hover { text-decoration: underline; }
.parts-danger { color: #b91c1c; }
.parts-link { color: #2266dd; }
.parts-link:hover { text-decoration: underline; }

.parts-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: #374151; }

.parts-hint { color: #6b7280; font-size: 0.8rem; line-height: 1.45; margin: 4px 0 10px; }
.parts-hint-inline { margin: 0; flex: 1 1 420px; }
.parts-hint code, .parts-preview code {
  background: #f3f4f6;
  border-radius: 4px;
  padding: 0 4px;
  font-size: 0.78rem;
}
.parts-muted { color: #9ca3af; }
.parts-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }

/* Grids */
.parts-grid { font-size: 0.85rem; border-radius: 6px; }
.parts-grid.tabulator { border: 1px solid #e5e7eb; }

/* Pills */
.parts-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #f3f4f6;
  color: #374151;
}
.parts-pill-unknown, .parts-pill-rejected { background: #fef3c7; color: #b45309; }
.parts-pill-suspect { background: #fee2e2; color: #b91c1c; }
.parts-pill-added   { background: #d1fae5; color: #065f46; }
.parts-pill-changed { background: #dbeafe; color: #1d4ed8; }
.parts-pill-warning { background: #fef3c7; color: #b45309; }

/* Product URL cell: text edits the cell, the arrow opens the page */
.parts-url { display: flex; align-items: center; gap: 6px; min-width: 0; }
.parts-url-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.parts-url-open { flex: none; color: #2266dd; font-weight: 600; text-decoration: none; padding: 0 2px; }
.parts-url-open:hover { text-decoration: underline; }

/* Settings */
.parts-setting { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; cursor: pointer; }
.parts-setting input { margin-top: 3px; }
.parts-setting .parts-hint { display: block; margin-top: 2px; }

/* Import dialog */
.parts-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(720px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.parts-dialog::backdrop { background: rgba(17,24,39,0.45); }
.parts-dialog-inner { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.parts-dialog h2 { font-size: 1.05rem; }
.parts-dialog textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  resize: vertical;
}
.parts-dialog-row { display: flex; align-items: center; gap: 10px; }
.parts-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.parts-preview { max-height: 40vh; overflow: auto; font-size: 0.83rem; }
.parts-preview h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280; margin: 10px 0 4px; }
.parts-preview ul { padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.parts-preview-summary { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.parts-preview-error { color: #b91c1c; font-weight: 500; }
.parts-preview-done { color: #065f46; font-weight: 600; }

/* Toast */
.parts-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  max-width: calc(100vw - 32px);
  background: #1f2937;
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 1000;
}
.parts-toast.show { opacity: 1; transform: translateY(0); }
.parts-toast.parts-toast-error { background: #dc2626; }
.parts-toast.parts-toast-warn { background: #b45309; }

@media (max-width: 640px) {
  .app-header { height: auto; padding: 6px 12px; }
  .header-inner { flex-wrap: wrap; row-gap: 4px; padding: 2px 0; }
  .header-left { flex-wrap: wrap; gap: 6px; flex: 1 0 100%; }
  .parts-add-form, .parts-add-form input, .parts-add-form select { width: 100%; }
  .parts-add-form input[name="sku"], .parts-add-form input[name="name"], .parts-add-form select { width: 100%; }
  .parts-narrow { width: calc(50% - 3px) !important; }
  .parts-asin, .parts-url-input { width: 100% !important; }
  .parts-toast { right: 16px; left: 16px; }
}
