/* ── Boutique Listing Workspace — Styles ─────────────── */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e0e2e6;
  --text: #1a1d23;
  --text-secondary: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --selected: #dbeafe;
  --rejected: #fee2e2;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  flex-shrink: 0;
}
.app-header h1 {
  font-size: 16px;
  font-weight: 600;
}
.header-sub {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 12px;
}
.header-lock-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}
.header-lock-btn:hover {
  background: var(--bg);
}

/* ── Login Overlay ─────────────────────────────────── */
.login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.login-overlay.active {
  display: flex;
}
.login-modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  width: 360px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.login-modal-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.login-modal h2 {
  font-size: 18px;
  margin-bottom: 8px;
}
.login-modal p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.login-modal .input-text {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  margin-bottom: 8px;
}
.login-modal .input-text:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.login-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 20px;
  margin-bottom: 8px;
}

/* ── Layout ─────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: calc(100vh - 52px);
}

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 16px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
}
.product-count {
  font-size: 12px;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-secondary);
}
/* ── Sort Bar ──────────────────────────────────────── */
.sidebar-sort {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 16px 8px;
}
.sort-label {
  font-size: 11px; color: var(--text-secondary); white-space: nowrap;
}
.sort-select {
  flex: 1; font-size: 12px; padding: 4px 6px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text); cursor: pointer;
}
.sort-select:focus { outline: none; border-color: var(--primary); }

.sidebar-search {
  padding: 8px 16px;
}
.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
}
.sidebar-search input:focus {
  border-color: var(--primary);
}
.product-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}
.product-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}
.product-list-item:hover {
  background: var(--bg);
}
.product-list-item.active {
  background: var(--selected);
}
.product-list-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}
.product-list-info {
  flex: 1;
  min-width: 0;
}
.product-list-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-list-code {
  font-size: 11px;
  color: var(--text-secondary);
}
.product-list-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* ── Quantity Badge & Sort Hint ─────────────────── */
.qty-badge {
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: var(--bg); color: var(--text-secondary);
  white-space: nowrap; font-weight: 500;
}
.qty-badge.qty-zero {
  background: #fde8e8; color: var(--danger); font-weight: 600;
}
.sort-hint {
  font-size: 10px; color: var(--text-secondary); white-space: nowrap;
}

/* ── Out-of-Stock Info Bar Badge ────────────────── */
.oos-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  background: #fde8e8; color: var(--danger);
  padding: 1px 8px; border-radius: 4px; margin-left: 8px; vertical-align: middle;
}
.loading {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ── Workspace ──────────────────────────────────────── */
.workspace {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-secondary);
}
.empty-icon {
  font-size: 48px;
  opacity: 0.5;
}
.empty-state h2 {
  font-size: 18px;
  color: var(--text);
}
.empty-state p {
  font-size: 14px;
  max-width: 360px;
  text-align: center;
}

/* ── Product Detail ─────────────────────────────────── */
.product-detail {
  padding: 20px 24px;
}

/* Product Info Bar */
.product-info-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
}
.product-info-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.product-thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
}
.product-info-text h2 {
  font-size: 15px;
  font-weight: 600;
}
.product-code {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: monospace;
}
.product-info-meta {
  display: flex;
  gap: 20px;
}
.meta-item {
  text-align: center;
}
.meta-item label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.meta-value {
  font-size: 15px;
  font-weight: 600;
}
.meta-code {
  font-size: 11px;
  font-family: monospace;
  font-weight: 400;
  color: var(--text-secondary);
}

/* ── Memo Section (between variant bar and tabs) ───── */
.memo-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 12px;
  padding: 10px 16px;
}
.memo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.memo-title {
  font-size: 13px;
  font-weight: 600;
}
.memo-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.memo-empty {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 0;
}
.memo-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
}
.memo-entry-date {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 1px;
  min-width: 80px;
}
.memo-entry-text {
  flex: 1;
  min-width: 0;
  color: var(--text);
}
.memo-entry-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.memo-entry-delete:hover {
  opacity: 1;
  color: var(--danger);
}
.memo-editor {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.memo-editor-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.memo-date-input {
  width: 140px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  flex-shrink: 0;
}
.memo-date-input:focus {
  border-color: var(--primary);
}
.memo-content-input {
  flex: 1;
  min-width: 0;
}

/* ── Tabs ───────────────────────────────────────────── */
.workspace-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.tab {
  padding: 8px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: none;
  transition: all 0.15s;
}
.tab.active {
  color: var(--primary);
  background: var(--bg);
  border-color: var(--border);
  border-bottom: 2px solid var(--primary);
}
.tab:hover:not(.active) {
  background: var(--bg);
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ── Panels ─────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
}
.panel h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.panel-header h3 {
  margin-bottom: 0;
}
.panel-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.panel-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Listing Content ────────────────────────────────── */
.listing-field {
  margin-bottom: 12px;
}
.listing-field label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.listing-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.description-text {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 6px;
  white-space: pre-wrap;
  font-size: 12px;
}
.input-text {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  font-family: var(--font);
}
.input-text:focus {
  border-color: var(--primary);
}
.input-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  font-family: var(--font);
  resize: vertical;
  line-height: 1.5;
}
.input-textarea:focus {
  border-color: var(--primary);
}
.field-source {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-style: italic;
}
.char-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 6px;
}
.listing-field-row {
  display: flex;
  gap: 24px;
}
.listing-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.refresh-status, .save-status {
  font-size: 12px;
  color: var(--text-secondary);
}
.risk-text {
  color: var(--danger);
}

/* ── Keywords ───────────────────────────────────────── */
.keyword-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.selected { background: var(--success); }
.status-dot.not-selected { background: var(--border); }
.status-dot.rejected { background: var(--danger); }
.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.keyword-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  line-height: 1.4;
}
.keyword-chip:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--selected);
}
.keyword-chip.selected {
  background: var(--selected);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 500;
}
.keyword-chip.rejected {
  background: var(--rejected);
  border-color: var(--danger);
  opacity: 0.55;
  text-decoration: line-through;
}
.keyword-chip.not-selected {
  background: var(--surface);
  border-color: var(--border);
  opacity: 0.85;
}
.keyword-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.badge {
  font-size: 12px;
  background: var(--primary);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
}

/* ── Pricing ────────────────────────────────────────── */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.pricing-item {
  background: var(--bg);
  padding: 12px;
  border-radius: 6px;
}
.pricing-item label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.pricing-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.pricing-section-header {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 0 2px;
  border-bottom: 1px solid var(--border);
}
.pricing-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.input-price {
  width: 180px;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  outline: none;
}
.input-price:focus {
  border-color: var(--primary);
}
.price-warning {
  font-size: 12px;
  color: var(--danger);
  font-weight: 500;
}

/* ── Images ─────────────────────────────────────────── */
.image-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 60px;
  padding: 8px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.image-card {
  position: relative;
  width: 160px;
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  cursor: grab;
  transition: all 0.15s;
}
.image-card:active { cursor: grabbing; }
.image-card.excluded {
  opacity: 0.4;
  border-style: dashed;
}
.image-card.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--selected);
}
.image-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}
.image-card-info {
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.image-order {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.image-role {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
}
.image-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.4);
  color: white;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-toggle:hover {
  background: rgba(0,0,0,0.7);
}
.image-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
}
.image-add-url {
  flex: 1;
}
.image-add-role {
  width: 160px;
  flex-shrink: 0;
}

/* ── Image File Upload ──────────────────────────────── */
.image-upload-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
}
.image-upload-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  flex-shrink: 0;
  transition: border-color 0.2s;
}
.image-upload-label:hover {
  border-color: var(--primary);
  color: var(--text-primary);
}
.image-upload-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.image-file-input {
  display: none;
}

/* ── Output ─────────────────────────────────────────── */
.output-json {
  background: #1a1d23;
  color: #e5e7eb;
  padding: 16px 20px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: "SF Mono", "Fira Code", monospace;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.output-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
}
.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 500px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
}
.modal-body {
  padding: 16px 20px;
}
.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 12px 0 4px;
}
.modal-body input, .modal-body textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
}
.modal-body textarea { resize: vertical; }
.modal-body input:focus, .modal-body textarea:focus {
  border-color: var(--primary);
}
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ── Add Hero Button ──────────────────────────────────── */
.add-hero-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: auto;
  margin-right: 6px;
  transition: all 0.15s;
  line-height: 1;
}
.add-hero-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── Add Listing Modal ────────────────────────────────── */
.add-listing-search {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.add-listing-search .input-text {
  flex: 1;
}
.modal-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.4;
}
.add-listing-results {
  max-height: 320px;
  overflow-y: auto;
}
.add-listing-empty,
.add-listing-loading {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}
.add-listing-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.add-listing-result-item:hover {
  background: var(--bg);
}
.add-listing-result-thumb {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}
.add-listing-result-info {
  flex: 1;
  min-width: 0;
}
.add-listing-result-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.add-listing-result-code {
  font-size: 11px;
  color: var(--text-secondary);
}
.add-listing-result-meta {
  font-size: 11px;
  color: var(--text-secondary);
}
.add-listing-result-action {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.add-listing-result-action .btn {
  padding: 4px 12px;
  font-size: 12px;
}
.add-listing-shop4-input {
  width: 180px;
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font);
}
.add-listing-shop4-input:focus {
  outline: none;
  border-color: var(--primary);
}
.add-listing-status {
  margin-top: 8px;
  font-size: 12px;
  text-align: center;
}
.add-listing-status.success {
  color: var(--success);
}
.add-listing-status.error {
  color: var(--danger);
}
.add-listing-already {
  display: inline-block;
  font-size: 11px;
  color: var(--success);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ── Image Lightbox ──────────────────────────────────── */
.image-lightbox {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
}
.image-lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  display: block;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.image-lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}
.image-lightbox-close:hover {
  background: rgba(255,255,255,0.3);
}

/* ── Competitor Listings ────────────────────────────── */
.competitor-heading {
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.competitor-add-form {
  margin: 8px 0 12px;
}
.competitor-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.competitor-input-row .input-text {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
}
.competitor-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.competitor-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  position: relative;
}
.competitor-card-left {
  flex-shrink: 0;
}
.competitor-thumb {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--border);
}
.competitor-card-body {
  flex: 1;
  min-width: 0;
}
.competitor-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.competitor-platform {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}
.competitor-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.competitor-title {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.competitor-notes {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-style: italic;
}
.competitor-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3px;
  gap: 8px;
}
.competitor-url {
  font-size: 10px;
  color: var(--primary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.competitor-url:hover {
  text-decoration: underline;
}
.competitor-time {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.competitor-card-actions {
  flex-shrink: 0;
}

/* ── Rakuten Main Image Generator ─────────────────────── */
.rakuten-input-row {
  margin-bottom: 12px;
}
.rakuten-input-row label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.rakuten-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-rakuten {
  background: #e53935;
}
.btn-rakuten:hover {
  background: #c62828;
}
.btn-rakuten:disabled {
  background: #ef9a9a;
  cursor: not-allowed;
}
.rakuten-results {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.rakuten-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.rakuten-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
  position: relative;
}
.rakuten-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(37,99,235,0.15);
}
.rakuten-card.selected {
  border-color: #e53935;
  box-shadow: 0 0 0 3px rgba(229,57,53,0.2);
}
.rakuten-card img {
  width: 100%;
  height: 240px;
  object-fit: contain;
  display: block;
  background: #fff;
}
.rakuten-card-label {
  padding: 8px 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}
.rakuten-card.selected .rakuten-card-label {
  color: #e53935;
  font-weight: 600;
}
.rakuten-card-error {
  border-color: #fee2e2;
  background: #fff8f8;
  cursor: default;
}
.rakuten-card-error-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 240px;
  gap: 8px;
  padding: 16px;
}
.rakuten-card-error-icon {
  font-size: 24px;
}
.rakuten-card-error-text {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}
.rakuten-card-check {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e53935;
  color: white;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.rakuten-card.selected .rakuten-card-check {
  display: flex;
}
.rakuten-card-preview {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.4);
  color: white;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 2;
}
.rakuten-card-preview:hover {
  background: rgba(0,0,0,0.7);
}
.rakuten-add-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Activity Log ─────────────────────────────────────── */
.activity-log {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.activity-entry {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.activity-entry:last-child {
  border-bottom: none;
}
.activity-entry:hover {
  background: var(--bg);
}
.activity-entry-icon {
  font-size: 18px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg);
  border-radius: 50%;
}
.activity-entry-body {
  flex: 1;
  min-width: 0;
}
.activity-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.activity-entry-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.activity-entry-time {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.activity-entry-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── SPU1 Grouping — Sidebar Group Styles ────────── */
.group-item {
  border-bottom: 1px solid var(--border);
}
.group-header {
  display: flex;
  align-items: center;
  padding: 10px 12px 10px 8px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.group-header:hover { background: var(--bg); }
.group-arrow {
  width: 20px;
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s;
  flex-shrink: 0;
  text-align: center;
}
.group-header.expanded .group-arrow { transform: rotate(90deg); }
.group-info { flex: 1; min-width: 0; }
.group-name {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.group-name .count {
  background: var(--bg);
  padding: 0 7px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}
.group-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.variants { display: none; }
.variants.open { display: block; }
.variant-item {
  display: flex;
  align-items: center;
  padding: 6px 12px 6px 36px;
  cursor: pointer;
  transition: background 0.1s;
  gap: 8px;
}
.variant-item:hover { background: var(--bg); }
.variant-item.active {
  background: #eef2ff;
  border-left: 3px solid var(--primary);
  padding-left: 33px;
}
.color-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.12);
}
.variant-name { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.variant-price { font-size: 12px; color: var(--text-secondary); }

.standalone-item {
  display: flex; align-items: center; padding: 10px 12px 10px 8px; cursor: pointer; transition: background 0.1s; gap: 10px;
}
.standalone-item:hover { background: var(--bg); }
.standalone-item.active {
  background: #eef2ff; border-left: 3px solid var(--primary); padding-left: 5px;
}
.standalone-icon { width: 20px; text-align: center; font-size: 12px; color: var(--text-secondary); }
.standalone-info { flex: 1; min-width: 0; }
.standalone-name { font-size: 13px; font-weight: 500; }
.standalone-code { font-size: 11px; color: var(--text-secondary); }
.standalone-price { font-size: 12px; color: var(--text-secondary); }

/* ── Variant Bar (above workspace tabs) ──────────── */
.variant-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px;
  min-height: 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.variant-bar-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-right: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.variant-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.variant-tab:hover {
  color: var(--text);
  background: rgba(0,0,0,0.02);
}
.variant-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.variant-tab .color-dot {
  width: 8px; height: 8px; border-color: rgba(0,0,0,0.1);
}
.variant-tab .item-code {
  font-size: 10px;
  color: inherit;
  opacity: 0.5;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: 200px; min-width: 200px; }
  .panel-row { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr 1fr; }
  .product-info-meta { display: none; }
}
@media (max-width: 640px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: auto; max-height: 200px; }
  .pricing-grid { grid-template-columns: 1fr; }
}

/* ── SPU1 Grouping — Sidebar Group Styles ────────── */
.group-item { border-bottom: 1px solid var(--border); }
.group-header {
  display: flex; align-items: center; padding: 10px 12px 10px 8px;
  cursor: pointer; transition: background 0.1s; user-select: none;
}
.group-header:hover { background: var(--bg); }
.group-arrow {
  width: 20px; font-size: 10px; color: var(--text-secondary);
  transition: transform 0.2s; flex-shrink: 0; text-align: center;
}
.group-header.expanded .group-arrow { transform: rotate(90deg); }
.group-info { flex: 1; min-width: 0; }
.group-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.group-name .count {
  background: var(--bg); padding: 0 7px; border-radius: 8px;
  font-size: 11px; font-weight: 500; color: var(--text-secondary);
}
.group-meta { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.variants { display: none; }
.variants.open { display: block; }
.variant-item {
  display: flex; align-items: center; padding: 6px 12px 6px 36px;
  cursor: pointer; transition: background 0.1s; gap: 8px;
}
.variant-item:hover { background: var(--bg); }
.variant-item.active {
  background: #eef2ff; border-left: 3px solid var(--primary); padding-left: 33px;
}
.color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.12); }
.variant-name { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.variant-price { font-size: 12px; color: var(--text-secondary); }
.standalone-item {
  display: flex; align-items: center; padding: 10px 12px 10px 8px; cursor: pointer; transition: background 0.1s; gap: 10px;
}
.standalone-item:hover { background: var(--bg); }
.standalone-item.active {
  background: #eef2ff; border-left: 3px solid var(--primary); padding-left: 5px;
}
.standalone-icon { width: 20px; text-align: center; font-size: 12px; color: var(--text-secondary); }
.standalone-info { flex: 1; min-width: 0; }
.standalone-name { font-size: 13px; font-weight: 500; }
.standalone-code { font-size: 11px; color: var(--text-secondary); }
.standalone-price { font-size: 12px; color: var(--text-secondary); }

/* ── Variant Bar (above workspace tabs) ──────────── */
.variant-bar {
  display: flex; align-items: center; gap: 4px; padding: 0 16px;
  min-height: 40px; background: var(--surface);
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.variant-bar-label {
  font-size: 11px; color: var(--text-secondary); font-weight: 500;
  margin-right: 6px; white-space: nowrap; flex-shrink: 0;
}
.variant-tab {
  display: flex; align-items: center; gap: 5px; padding: 6px 12px;
  font-size: 12px; font-weight: 500; background: transparent; border: none;
  border-bottom: 2px solid transparent; cursor: pointer; color: var(--text-secondary);
  transition: all 0.15s; font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.variant-tab:hover { color: var(--text); background: rgba(0,0,0,0.02); }
.variant-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.variant-tab .color-dot { width: 8px; height: 8px; border-color: rgba(0,0,0,0.1); }
.variant-tab .item-code { font-size: 10px; color: inherit; opacity: 0.5; }

/* ── Amazon Tab ──────────────────────────────────── */
.amazon-snapshot { min-height: 120px; }
.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
.snapshot-item {
  background: var(--bg-secondary);
  border-radius: 6px;
  padding: 10px 12px;
}
.snapshot-item.snapshot-full { grid-column: 1 / -1; }
.snapshot-item label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.snapshot-value { font-size: 14px; font-weight: 600; }
.snapshot-value.code { font-family: monospace; font-size: 13px; }
.amazon-not-listed { padding: 0; }

/* ── Amazon Draft Editor ─────────────────────────── */
.amz-draft-field {
  margin-bottom: 16px;
}
.amz-draft-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.amz-draft-field .char-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 6px;
}
.amz-draft-field .char-count.over-limit {
  color: var(--danger);
  font-weight: 600;
}
.amz-bullet-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.amz-bullet-num {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-top: 6px;
}
.amz-bullet-input {
  flex: 1;
  min-width: 0;
  resize: vertical;
}
.amz-byte-counter {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 55px;
  text-align: right;
  padding-top: 6px;
  flex-shrink: 0;
}
.amz-byte-counter.over-limit {
  color: var(--danger);
  font-weight: 600;
}
.amz-draft-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  .snapshot-grid { grid-template-columns: repeat(2, 1fr); }
  .amz-bullet-row { flex-wrap: wrap; }
  .amz-byte-counter { width: 100%; text-align: left; padding-left: 32px; }
}

/* ── Rakuten Tab ─────────────────────────────────────── */

.warning-banner {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #856404;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-error {
  border-color: #e74c3c !important;
  box-shadow: 0 0 0 1px #e74c3c;
}

.rakuten-snapshot {
  /* inherits from snapshot-grid */
}

.rakuten-mapping-error {
  /* container for mapping error state */
}

/* ── Rakuten Link Status ─────────────────────────────── */

.rakuten-link-status {
  margin-bottom: 12px;
}

.link-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
}

.link-status-bar.linked {
  background: #d4edda;
  border: 1px solid #28a745;
  color: #155724;
}

.link-status-bar.not-linked {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
}

.link-status-bar.error {
  background: #f8d7da;
  border: 1px solid #dc3545;
  color: #721c24;
}

.link-status-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.link-status-text {
  font-weight: 600;
}

.link-status-detail {
  font-size: 11px;
  color: inherit;
  opacity: 0.75;
  margin-left: auto;
}

/* ── Rakuten Variant Summary ─────────────────────────── */

.variant-summary-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text);
  list-style: revert; /* show default disclosure triangle */
}

.variant-summary-count {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: normal;
}

.variant-table-wrap {
  max-height: 260px;
  overflow-y: auto;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.variant-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.variant-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.variant-table th {
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  white-space: nowrap;
}

.variant-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.variant-table tbody tr:hover {
  background: var(--bg);
}

.variant-table td.code {
  font-family: monospace;
  font-size: 11px;
}

.variant-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--border);
}
