/* PartStop CRM — minimal, brand colors: #243E8E royal blue, #F7E821 yellow, #000 black */
:root {
  --ps-blue: #243E8E;
  --ps-yellow: #F7E821;
  --ps-black: #000;
  --ps-grey-50: #f7f8fb;
  --ps-grey-200: #e4e7ee;
  --ps-grey-400: #9aa1ad;
  --ps-grey-700: #3b4252;
  --ps-text: #1a1d23;
  --ps-success: #1b8a4a;
  --ps-error: #c2362d;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ps-text);
  background: var(--ps-grey-50);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--ps-blue); }

.topbar {
  background: var(--ps-black);
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 4px solid var(--ps-yellow);
}
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: 0.5px; }
.brand-tag { color: var(--ps-yellow); margin-left: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.topbar nav { display: flex; align-items: center; gap: 14px; }
.user-email { color: white; opacity: 0.9; font-size: 13px; }
.role-badge {
  background: var(--ps-yellow);
  color: var(--ps-black);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
}
.btn-ghost {
  color: white;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

.container { max-width: 1200px; margin: 28px auto; padding: 0 24px; }
.card {
  background: white;
  border: 1px solid var(--ps-grey-200);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.card-narrow { max-width: 420px; margin: 60px auto; }

h1 { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ps-grey-700); margin: 0 0 12px; }
.muted { color: var(--ps-grey-400); }
.mt-1 { margin-top: 16px; }

label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 13px; color: var(--ps-grey-700); }
input[type=email], input[type=password], input[type=text] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--ps-grey-200);
  border-radius: var(--radius);
  font-size: 14px;
  margin-top: 4px;
  font-family: inherit;
}
input:focus { outline: 2px solid var(--ps-blue); outline-offset: -1px; border-color: var(--ps-blue); }

.btn-primary {
  background: var(--ps-blue);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
}
.btn-primary:hover { background: #1c3171; }

.flash {
  padding: 11px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 14px;
}
.flash-error { background: #fdecea; color: var(--ps-error); border: 1px solid #f6c3be; }
.flash-success { background: #e6f5ec; color: var(--ps-success); border: 1px solid #b9e1c8; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid var(--ps-grey-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table th {
  background: var(--ps-grey-50);
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ps-grey-700);
  border-bottom: 2px solid var(--ps-grey-200);
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--ps-grey-200);
}
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--ps-grey-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
code { font-family: ui-monospace, SF Mono, Menlo, Monaco, monospace; font-size: 13px; }
.big-sku { font-size: 16px; background: var(--ps-grey-50); padding: 4px 10px; border-radius: var(--radius); }

.pill {
  display: inline-block;
  padding: 2px 10px;
  background: var(--ps-blue);
  color: white;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

dl { margin: 0; }
dl dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ps-grey-400);
  margin-top: 8px;
}
dl dd { margin: 2px 0 0; font-size: 14px; }

.qr-wrap { display: flex; justify-content: center; margin: 24px 0; }
.qr-wrap img { border: 1px solid var(--ps-grey-200); padding: 12px; background: white; }
details summary { cursor: pointer; font-size: 13px; color: var(--ps-grey-700); padding: 6px 0; }

.back-link { display: inline-block; margin-bottom: 12px; text-decoration: none; font-size: 13px; }

.footer {
  text-align: center;
  padding: 20px;
  color: var(--ps-grey-400);
  font-size: 12px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

/* Dashboard additions for Stage 2A — pagination, filters, search */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }

.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-bar input[type=search],
.filter-bar select {
  padding: 7px 11px;
  border: 1px solid var(--ps-grey-200);
  border-radius: var(--radius);
  background: white;
  font-size: 13px;
  font-family: inherit;
}
.filter-bar input[type=search] { flex: 1; min-width: 220px; }
.filter-bar select { min-width: 160px; }
.btn-inline { width: auto !important; padding: 8px 16px; font-size: 13px; }
.btn-ghost-dark {
  color: var(--ps-grey-700);
  border: 1px solid var(--ps-grey-200);
  background: white;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  text-decoration: none;
}
.btn-ghost-dark:hover { background: var(--ps-grey-50); }

.small-code { font-size: 12px; color: var(--ps-grey-700); }
.empty { text-align: center; color: var(--ps-grey-400); padding: 32px !important; }

.pagination {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
  font-size: 13px;
}
.pagination a {
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid var(--ps-grey-200);
  border-radius: var(--radius);
  background: white;
}
.pagination a:hover { background: var(--ps-grey-50); }
.pagination .disabled { color: var(--ps-grey-400); padding: 6px 14px; }
.page-info { color: var(--ps-grey-700); }

/* SKU detail page enhancements */
.sku-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.brand-chip {
  display: inline-block;
  padding: 3px 11px;
  background: var(--ps-yellow);
  color: var(--ps-black);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.span-2 { grid-column: span 2; }
@media (max-width: 720px) { .span-2 { grid-column: span 1; } }
.bullet-list { padding-left: 18px; margin: 0; }
.bullet-list li { margin-bottom: 6px; line-height: 1.5; }
.marketing-desc {
  background: var(--ps-grey-50);
  padding: 10px 14px;
  border-left: 3px solid var(--ps-blue);
  border-radius: 3px;
  margin: 0 0 10px;
  line-height: 1.5;
}
.spec-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
@media (max-width: 540px) { .spec-list { grid-template-columns: 1fr; } }
.spec-list dt { font-weight: 600; color: var(--ps-grey-700); }
.reviews-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px) { .reviews-grid { grid-template-columns: 1fr; } }
.review {
  background: var(--ps-grey-50);
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--ps-grey-200);
}
.review-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.rating { color: #d49a00; font-weight: 700; margin-left: auto; }
.review p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ps-grey-700); }
.break-all { word-break: break-all; }
.hint { color: var(--ps-grey-700); font-style: italic; font-size: 13px; }
.small { font-size: 12px; }

/* Stage 2B — fitment & cross-ref tables */
.fitment-table, .xref-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 13px;
}
.fitment-table th, .xref-table th {
  text-align: left;
  padding: 6px 8px;
  background: var(--ps-grey-50);
  border-bottom: 1px solid var(--ps-grey-200);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ps-grey-700);
}
.fitment-table td, .xref-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--ps-grey-200);
}
.xref-table code { font-size: 12px; }
.conf-primary { color: var(--ps-success); font-weight: 700; }
.conf-high { color: var(--ps-success); }
.conf-medium { color: #b46e00; }
.conf-low { color: var(--ps-grey-400); }

/* Stage 2C — top nav links + order/customer styling */
.nav-link {
  color: white;
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 13px;
  opacity: 0.85;
}
.nav-link:hover { background: rgba(255,255,255,0.1); opacity: 1; }

/* Source pills (orders) */
.source-amazon { background: #FF9900 !important; color: white; }
.source-ebay { background: #E53238 !important; color: white; }
.source-walmart { background: #0071CE !important; color: white; }
.source-online { background: var(--ps-blue) !important; color: white; }
.source-phone { background: #6B7280 !important; color: white; }
.source-offline { background: var(--ps-grey-700) !important; color: white; }

/* Payment statuses */
.pay-paid { color: var(--ps-success); font-weight: 700; font-size: 12px; }
.pay-pending { color: #b46e00; font-weight: 600; font-size: 12px; }
.pay-refunded { color: var(--ps-error); font-weight: 600; font-size: 12px; }
.pay-failed { color: var(--ps-error); font-weight: 700; font-size: 12px; }

/* Order statuses */
.status-completed { color: var(--ps-success); font-weight: 600; font-size: 12px; }
.status-shipped { color: var(--ps-blue); font-weight: 600; font-size: 12px; }
.status-processing { color: #b46e00; font-size: 12px; }
.status-pending { color: var(--ps-grey-700); font-size: 12px; }
.status-cancelled { color: var(--ps-error); font-size: 12px; }
.status-refunded { color: var(--ps-error); font-size: 12px; }
.status-active { color: var(--ps-success); font-weight: 600; font-size: 12px; }

/* Stage 2D — marketplace dots in dashboard */
.mp-dot {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  margin-right: 3px;
  color: white;
  font-family: ui-monospace, monospace;
}
.mp-ebay { background: #E53238; }
.mp-amazon { background: #FF9900; color: #000; }
.mp-walmart { background: #0071CE; }
.mp-gmc { background: #4285F4; }

/* SKU image preview */
.sku-image {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--ps-grey-200);
  border-radius: var(--radius);
  background: white;
  padding: 8px;
}

/* Phase 2.1 — edit forms */
.action-buttons { display: flex; gap: 8px; align-items: center; }
.btn-danger {
  background: var(--ps-error);
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-danger:hover { background: #a02822; }

.edit-form input[type=text], .edit-form input[type=number], .edit-form textarea, .edit-form select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--ps-grey-200);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  background: white;
  margin-top: 3px;
}
.edit-form textarea { resize: vertical; min-height: 60px; }
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.checkbox-row input { width: auto !important; margin-top: 0 !important; }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  padding: 16px 0;
  border-top: 1px solid var(--ps-grey-200);
  align-items: center;
}
.form-actions .btn-danger { margin-left: auto; }

/* Audit log */
.audit-table .diff-old { color: var(--ps-error); text-decoration: line-through; }
.audit-table .diff-new { color: var(--ps-success); font-weight: 600; }
.action-pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--ps-grey-50);
  border: 1px solid var(--ps-grey-200);
  border-radius: 3px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
}

/* Reports view */
.range-pills { display: flex; gap: 6px; }
.range-pill {
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--ps-grey-200);
  border-radius: var(--radius);
  background: white;
  color: var(--ps-grey-700);
  font-size: 13px;
}
.range-pill:hover { background: var(--ps-grey-50); }
.range-pill.active { background: var(--ps-blue); color: white; border-color: var(--ps-blue); }

.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--ps-grey-200);
  margin-bottom: 16px;
  gap: 4px;
}
.tab {
  text-decoration: none;
  padding: 10px 18px;
  border-bottom: 3px solid transparent;
  color: var(--ps-grey-700);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: -2px;
}
.tab:hover { color: var(--ps-blue); }
.tab.active { color: var(--ps-blue); border-color: var(--ps-yellow); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: white;
  border: 1px solid var(--ps-grey-200);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ps-grey-400);
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.kpi-delta { font-size: 12px; margin-top: 4px; }
.kpi-delta.up { color: var(--ps-success); }
.kpi-delta.down { color: var(--ps-error); }

.bar-wrap {
  position: relative;
  background: var(--ps-grey-50);
  border-radius: 3px;
  height: 22px;
  overflow: hidden;
  min-width: 120px;
}
.bar {
  height: 100%;
  background: var(--ps-blue);
  transition: width 0.3s;
}
.bar-amazon { background: #FF9900; }
.bar-ebay { background: #E53238; }
.bar-walmart { background: #0071CE; }
.bar-online { background: #22d3ee; }
.bar-phone { background: #a78bfa; }
.bar-offline { background: #9aa3b8; }

/* Procurement stage list */
.stage-list { padding-left: 22px; margin: 0; font-size: 13px; line-height: 1.7; }
.stage-list li { color: var(--ps-grey-700); }

.taxonomy-subs { padding-left: 18px; margin: 0; font-size: 13px; line-height: 1.7; color: var(--ps-grey-700); }
.taxonomy-subs li { margin-bottom: 1px; }

/* Topbar search */
.topbar-search { display: inline-block; margin: 0 8px; }
.topbar-search input[type=search] {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 5px 11px;
  border-radius: var(--radius);
  font-size: 13px;
  width: 200px;
}
.topbar-search input[type=search]::placeholder { color: rgba(255,255,255,0.72); }
.topbar-search input[type=search]:focus {
  background: rgba(255,255,255,0.18);
  outline: none;
  border-color: var(--ps-yellow);
}

/* Brand swatch (Design Studio) */
.brand-swatch {
  width: 110px;
  padding: 14px 10px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  border-radius: var(--radius);
  line-height: 1.4;
}

.token-pre {
  background: var(--ps-black);
  color: #6ee7b7;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-family: ui-monospace, monospace;
  font-size: 13px;
  word-break: break-all;
  white-space: pre-wrap;
  border: 2px solid var(--ps-grey-200);
}
.bar-label {
  position: absolute;
  top: 0;
  left: 8px;
  line-height: 22px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ps-text);
  font-variant-numeric: tabular-nums;
}
