:root {
  --primary: #1a1a2e;
  --accent: #ff9800;
  --accent-light: #fff3e0;
  --success: #4caf50;
  --danger: #f44336;
  --bg: #f5f5f5;
  --card: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a2e;
  --text-light: #666;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.login-card {
  background: white; padding: 40px; border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center; width: 90%; max-width: 400px;
}
.login-logo { font-size: 48px; margin-bottom: 16px; }
.login-card h1 { font-size: 24px; margin-bottom: 8px; }
.login-subtitle { color: var(--text-light); font-size: 13px; margin-bottom: 28px; }
#login-form input {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--border); border-radius: 10px;
  font-size: 16px; margin-bottom: 12px; transition: border 0.2s;
}
#login-form input:focus { border-color: var(--accent); outline: none; }
#login-form button {
  width: 100%; padding: 14px;
  background: var(--primary); color: white; border: none;
  border-radius: 10px; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
}
#login-form button:hover { background: #2a2a4e; }
.error-msg { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 8px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: var(--primary); color: white;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.logo { font-weight: 600; font-size: 16px; }
.back-link { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 14px; }
.back-link:hover { color: white; }
.btn-ghost {
  background: transparent; color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 16px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: white; }
.container { max-width: 900px; margin: 0 auto; padding: 24px 20px; }
.container h2 { font-size: 18px; margin-bottom: 16px; }
.search-section { margin-bottom: 32px; }
.search-bar { display: flex; gap: 8px; }
.search-bar input {
  flex: 1; padding: 14px 16px;
  border: 2px solid var(--border); border-radius: 10px; font-size: 16px;
}
.search-bar input:focus { border-color: var(--accent); outline: none; }
.create-section { margin-bottom: 32px; }
.create-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; }
.create-form input {
  padding: 12px 14px; border: 2px solid var(--border);
  border-radius: 10px; font-size: 14px;
}
.create-form input:focus { border-color: var(--accent); outline: none; }
.btn-primary {
  background: var(--primary); color: white; border: none;
  padding: 12px 24px; border-radius: 10px; font-size: 14px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-primary:hover { background: #2a2a4e; }
.results-section { margin-bottom: 32px; }
.count-badge { font-size: 13px; color: var(--text-light); font-weight: normal; }
/* === PH 列表：可排序表格 === */
.product-list {
  display: flex; flex-direction: column;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.product-row, .product-header-row {
  display: grid;
  grid-template-columns:
    56px
    90px
    120px
    150px
    minmax(140px, 1fr)
    95px
    110px
    85px
    80px
    50px
    90px
    40px;
  align-items: center;
  background: var(--card);
  text-decoration: none; color: inherit;
}
.product-header-row {
  background: var(--bg-soft);
  font-size: 11px; font-weight: 600;
  color: var(--text-light); letter-spacing: 0.3px;
  text-transform: uppercase;
  position: sticky; top: 0; z-index: 2;
}
.product-header-row .ph-cell {
  padding: 10px 8px;
  display: flex; align-items: center; gap: 4px;
  user-select: none;
}
.product-header-row .ph-cell.sortable { cursor: pointer; }
.product-header-row .ph-cell.sortable:hover { color: var(--primary); }
.sort-indicator { font-size: 9px; opacity: 0.6; }
.sort-indicator.active { opacity: 1; color: var(--primary); }
.product-row { padding: 0; cursor: pointer; transition: background 0.1s; border-top: 1px solid var(--border); }
.product-row:hover { background: var(--bg-soft); }
.product-row .pr-cell { padding: 8px 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.product-row .pr-thumb { padding: 6px 8px; }
.product-row .pr-thumb img {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border); display: block;
  background: var(--bg);
}
.product-row .pr-thumb .pr-noimg {
  width: 48px; height: 48px; border-radius: 6px;
  border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-light); background: var(--bg);
}
.product-row .pr-id { font-weight: 700; color: var(--primary); }
.product-row .pr-name { color: var(--text); }
.product-row .pr-cust { font-weight: 500; }
.product-row .pr-sales-order {
  display: inline-block; color: #1a73e8; font-weight: 600;
  text-decoration: none; padding: 1px 6px;
  border-radius: 4px; background: #e8f0fe;
  font-size: 12px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.product-row .pr-sales-order:hover { background: #d2e3fc; }
.product-row .pr-no-sales { color: var(--text-light); font-size: 11px; font-style: italic; }
.product-row .pr-status {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; line-height: 1.4; background: var(--bg-soft); color: var(--text-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.product-row .pr-status.sold { background: #fff4e5; color: #b76b00; }
.product-row .pr-status.stock { background: #e6f4ea; color: #1e7e34; }
.product-row .pr-status.ad { background: #fce8f3; color: #b51f70; }
.product-row .pr-price { font-weight: 700; color: var(--primary); text-align: right; padding-right: 12px; }
.product-row .pr-files { text-align: center; color: var(--text-light); }
.product-row .pr-ad-cell { text-align: center; padding: 4px; }
.pr-ad-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-size: 12px; cursor: pointer; color: var(--text-light);
  line-height: 1.4;
}
.pr-ad-btn.on { background: #fff4e5; color: #b76b00; border-color: #ffd9a8; }
.product-row .pr-cell.right { text-align: right; }
.product-row .pr-cell.center { text-align: center; }
@media (max-width: 1100px) {
  .product-header-row, .product-row {
    grid-template-columns: 50px 80px 110px 130px minmax(120px, 1fr) 80px 80px 70px 80px;
  }
  .product-header-row > .ph-cell:nth-child(8),
  .product-header-row > .ph-cell:nth-child(9),
  .product-header-row > .ph-cell:nth-child(10),
  .product-header-row > .ph-cell:nth-child(11),
  .product-header-row > .ph-cell:nth-child(12),
  .product-row > .pr-cell:nth-child(8),
  .product-row > .pr-cell:nth-child(9),
  .product-row > .pr-cell:nth-child(10),
  .product-row > .pr-cell:nth-child(11),
  .product-row > .pr-cell:nth-child(12) { display: none; }
}
@media (max-width: 700px) {
  .product-header-row, .product-row {
    grid-template-columns: 48px 70px 1fr 70px;
  }
  .product-header-row > .ph-cell:nth-child(n+5),
  .product-row > .pr-cell:nth-child(n+5) { display: none; }
}
.product-hero {
  width: 200px;
  height: 200px;
  border-radius: 12px;
}
.product-hero.placeholder {
  font-size: 14px;
  background: var(--bg);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.product-hero.placeholder:hover {
  background: var(--accent-light, #f0f4ff);
  border-color: var(--accent, #4a7dff);
  color: var(--accent, #4a7dff);
}

/* Stone Summary box (renders inside POS 石資料 section) */
.stone-summary {
  margin-top: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fff8e6 0%, #fff3d6 100%);
  border: 1px solid #f0d68c;
  border-radius: 10px;
  font-size: 13px;
}
.stone-sum-header {
  font-size: 13px;
  font-weight: 700;
  color: #8a6a1f;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}
.stone-sum-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #e8cf94;
}
.stone-sum-stat {
  text-align: center;
  padding: 8px;
  background: rgba(255,255,255,0.55);
  border-radius: 8px;
}
.stone-sum-num {
  font-size: 22px;
  font-weight: 700;
  color: #6b4f12;
  line-height: 1.2;
}
.stone-sum-unit {
  font-size: 13px;
  font-weight: 600;
  color: #8a6a1f;
}
.stone-sum-label {
  font-size: 11px;
  color: #8a6a1f;
  margin-top: 2px;
  letter-spacing: 0.5px;
}
.stone-sum-row {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  font-size: 12px;
  align-items: baseline;
}
.stone-sum-key {
  flex: 0 0 60px;
  color: #8a6a1f;
  font-weight: 600;
}
.stone-sum-val {
  flex: 1;
  color: #3a2c0e;
  word-break: break-word;
}
.stone-sum-x {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  background: #f0d68c;
  color: #6b4f12;
  border-radius: 8px;
  margin-left: 2px;
  font-weight: 600;
}
.stone-sum-empty {
  color: #b89c5e;
  font-style: italic;
}
.hero-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.7;
}

/* Marketing 資料區（Hub 自訂，紫色主題同 POS 藍色區分） */
.marketing-section {
  border: 1px solid #d5bef5;
  background: linear-gradient(135deg, #faf6ff 0%, #f3e9fd 100%);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}
.marketing-section .spec-title { color: #6a3fb5; }
.marketing-block {
  background: rgba(255,255,255,0.7);
  border: 1px solid #e2d3f7;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.marketing-block:last-child { margin-bottom: 0; }
.marketing-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.marketing-block-label {
  font-size: 12px;
  font-weight: 700;
  color: #6a3fb5;
  letter-spacing: 0.3px;
}
.marketing-block-text {
  font-size: 13px;
  color: #34224f;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}
.marketing-textarea {
  width: 100%;
  min-height: 80px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 12px;
  border: 1px solid #d5bef5;
  border-radius: 8px;
  background: #fff;
  color: #34224f;
  box-sizing: border-box;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.marketing-textarea:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}
#marketing-input-marketing_story { min-height: 280px; }
#marketing-input-marketing_pricing { min-height: 140px; }
#marketing-input-marketing_notes { min-height: 140px; }
.marketing-block-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.btn-save-mini {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid #8bc34a;
  background: #fff;
  color: #4a7d24;
  border-radius: 6px;
  cursor: pointer;
}
.btn-save-mini:hover { background: #f1f8e9; }
.marketing-save-status {
  font-size: 11px;
  margin-left: 4px;
  color: #888;
  min-width: 60px;
  display: inline-block;
}
.marketing-save-status.ok { color: #4a7d24; }
.marketing-save-status.err { color: #c62828; }
.marketing-hint-inline {
  font-size: 11px;
  font-weight: 400;
  color: #9b7dcf;
  margin-left: 6px;
}
.btn-copy {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid #d5bef5;
  background: #fff;
  color: #6a3fb5;
  border-radius: 6px;
  cursor: pointer;
}
.btn-copy:hover { background: #f3e9fd; }
.marketing-edit-block {
  margin-top: 16px;
  padding: 14px 16px;
  background: #faf6ff;
  border: 1px solid #d5bef5;
  border-radius: 12px;
}
.marketing-edit-block .spec-title { color: #6a3fb5; margin: 0 0 12px; }
.marketing-edit-block textarea {
  width: 100%;
  box-sizing: border-box;
}
.hero-wrapper {
  position: relative;
  flex-shrink: 0;
}
.hero-wrapper .product-hero { cursor: pointer; }
.hero-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.hero-wrapper:hover .hero-overlay { opacity: 1; pointer-events: auto; }
.hero-action {
  background: rgba(255,255,255,0.95);
  color: #222;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.hero-action:hover { background: #fff; }
.hero-action.danger { color: #c0392b; }
.hero-action.danger:hover { background: #fde8e6; }
@media (max-width: 640px) {
  .product-hero { width: 100%; height: 220px; }
  .product-thumb { width: 48px; height: 48px; }
}
/* Legacy class aliases — kept so old template calls don't 404; visual handled by .pc-* */
.product-id { font-weight: 700; font-size: 16px; color: var(--primary); }
.product-id-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.sales-order-tag {
  background: #e8f0fe; color: #1a73e8;
  padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600;
  text-decoration: none; display: inline-block; white-space: nowrap;
}
.sales-order-tag:hover { background: #d2e3fc; color: #1557b0; }
.product-name { color: var(--text-light); font-size: 14px; margin-top: 4px; }
.product-meta { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-light); flex-wrap: wrap; }
.product-meta span { display: flex; align-items: center; gap: 4px; }
.product-card-right { text-align: right; }
.file-count { font-size: 24px; font-weight: 700; color: var(--accent); }
.file-count-label { font-size: 11px; color: var(--text-light); }
.cross-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.cross-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  margin-bottom: 8px;
}
.cross-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.cross-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--bg);
  display: block;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.cross-item:hover {
  background: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
}
.cross-name { font-weight: 600; font-size: 13px; color: var(--primary); }
.cross-meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: 11px; color: var(--text-light); margin-top: 4px;
}
.cross-more {
  grid-column: 1/-1;
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  padding: 8px;
}
.product-header {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); margin-bottom: 24px;
}
.product-header-info { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.info-field { display: flex; flex-direction: column; }
.info-field label {
  font-size: 12px; color: var(--text-light); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 4px;
}
.info-field input, .info-field textarea, .info-field select {
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
}
.info-field input:focus, .info-field textarea:focus, .info-field select:focus {
  border-color: var(--accent); outline: none;
}
/* Spec sections (detailed product specs) */
.spec-section { margin-top: 16px; }
.spec-title {
  font-size: 14px; color: var(--primary); margin: 0 0 4px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.info-field.wide { grid-column: 1 / -1; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 12px; }
.gallery-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); display: block;
}
.gallery-grid a { position: relative; display: block; }
.gallery-grid a:hover img { border-color: var(--primary); }
.gallery-video-ph {
  width: 100%; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  background: var(--bg, #f5f6fa);
}
.video-badge {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0,0,0,.72); color: #fff; font-size: 11px;
  padding: 2px 8px; border-radius: 999px; pointer-events: none;
}
.product-price {
  margin-top: 6px; font-size: 15px; font-weight: 700; color: var(--primary);
}
.edit-actions { margin-top: 16px; display: flex; gap: 8px; }
.btn-save {
  background: var(--success); color: white; border: none;
  padding: 10px 20px; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.btn-cancel {
  background: var(--border); color: var(--text); border: none;
  padding: 10px 20px; border-radius: 8px; cursor: pointer;
}
.upload-section { margin-bottom: 32px; }
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s; background: var(--card);
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: var(--accent-light); }
.drop-zone p { margin: 4px 0; }
.drop-zone .hint { font-size: 12px; color: var(--text-light); }
.upload-progress { margin-top: 12px; }
.upload-progress-item {
  background: var(--accent-light); padding: 8px 12px;
  border-radius: 8px; margin-bottom: 4px; font-size: 13px;
}
.upload-progress-item.success { background: #e8f5e9; }
.upload-progress-item.error { background: #ffebee; }
.files-section { margin-bottom: 32px; }
.file-category { margin-bottom: 24px; }
.category-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; font-size: 16px; font-weight: 600;
}
.category-icon { font-size: 20px; }
.category-count { font-size: 13px; color: var(--text-light); font-weight: normal; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.file-item {
  background: var(--card); border-radius: 10px; padding: 12px;
  box-shadow: var(--shadow); position: relative;
}
.file-item img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; margin-bottom: 8px; }
.file-icon { font-size: 32px; text-align: center; padding: 20px 0; }
.file-name { font-size: 12px; color: var(--text); word-break: break-all; margin-bottom: 4px; }
.file-size { font-size: 11px; color: var(--text-light); }
.file-actions { display: flex; gap: 4px; margin-top: 8px; }
.file-actions a, .file-actions button {
  flex: 1; text-align: center; font-size: 11px; padding: 4px 8px;
  border-radius: 6px; text-decoration: none; border: none; cursor: pointer;
}
.btn-download { background: var(--accent-light); color: var(--accent); }
.btn-delete { background: #ffebee; color: var(--danger); }
.status-badge {
  display: inline-block; padding: 4px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.status-draft { background: #f5f5f5; color: #888; }
.status-production { background: #e3f2fd; color: #1565c0; }
.status-marketing { background: #f3e5f5; color: #7b1fa2; }
.status-ready { background: #e8f5e9; color: #2e7d32; }
.status-selling { background: #fff3e0; color: #e65100; }
.status-sold { background: #ffebee; color: #c62828; }
.stats-bar {
  display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap;
}
.stat-item {
  background: var(--card); border-radius: var(--radius); padding: 16px 20px;
  box-shadow: var(--shadow); flex: 1; min-width: 120px; text-align: center;
}
.stat-num { font-size: 28px; font-weight: 700; color: var(--primary); display: block; }
.stat-label { font-size: 12px; color: var(--text-light); }
.filter-bar {
  display: flex; gap: 8px; margin-top: 8px;
}
.filter-bar select {
  padding: 8px 12px; border: 2px solid var(--border); border-radius: 8px;
  font-size: 14px; background: var(--card); cursor: pointer;
}
.filter-bar select:focus { border-color: var(--accent); outline: none; }
.company-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
}
.company-mihk { background: #e3f2fd; color: #1565c0; }
.company-mimy { background: #fff3e0; color: #e65100; }
.cat-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; background: #f3e5f5; color: #7b1fa2;
}
.status-imported { background: #f5f5f5; color: #888; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-light); }
/* Detail page action bar + related cards + hint */
.action-bar { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.note-box {
  margin-top: 16px; padding: 12px 16px;
  background: #fff8e1; border-left: 4px solid #ffc107;
  border-radius: 8px; font-size: 13px; color: #5d4037;
}
.note-box code {
  background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 4px;
  font-size: 12px;
}
.hint-box {
  margin: 12px 0; padding: 12px 16px;
  background: #e3f2fd; border-left: 4px solid #1565c0;
  border-radius: 8px; font-size: 13px; color: #0d47a1;
}
.related-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.related-card {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; background: var(--bg);
  text-decoration: none; color: inherit; display: block;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.related-card:hover {
  background: #fff; border-color: var(--primary); transform: translateY(-1px);
}
.related-id { font-family: monospace; font-weight: 600; color: var(--primary); }
.related-meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-light); margin-top: 4px;
}
@media (max-width: 640px) {
  .create-form { grid-template-columns: 1fr; }
  .product-header-info { grid-template-columns: 1fr; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .container { padding: 16px; }
  .search-bar { flex-direction: column; }
}

/* ===== Order ↔ Product link section ===== */
.link-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin: 16px 0;
}
.link-section h3 { margin: 0 0 6px; font-size: 16px; color: var(--primary); }
.hint-text { color: var(--text-light); font-size: 13px; margin: 0 0 12px; }
.link-form {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
}
.link-form input {
  flex: 1; min-width: 140px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text);
}
.link-form input:focus { outline: none; border-color: var(--accent); }
.error-msg {
  background: #fee; color: #c33; padding: 8px 12px; border-radius: 6px;
  font-size: 13px; margin-bottom: 8px;
}
.empty-inline {
  color: var(--text-light); font-size: 13px;
  padding: 12px; text-align: center;
  border: 1px dashed var(--border); border-radius: 8px;
}
.linked-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.linked-card {
  display: flex; gap: 10px; padding: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; text-decoration: none; color: inherit;
  transition: border-color 0.15s, transform 0.1s;
}
.linked-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.linked-thumb {
  width: 72px; height: 72px; flex-shrink: 0;
  background: #eee; border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.linked-thumb img { width: 100%; height: 100%; object-fit: cover; }
.linked-thumb .no-thumb { font-size: 11px; color: #999; }
.linked-body { flex: 1; min-width: 0; }
.linked-rid {
  font-family: monospace; font-weight: 700; color: var(--primary);
  font-size: 13px;
}
.linked-name {
  font-size: 13px; color: var(--text); margin: 2px 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.linked-meta { font-size: 11px; color: var(--text-light); display: flex; gap: 8px; }
.linked-note {
  font-size: 11px; color: var(--text-light); margin-top: 4px;
  font-style: italic;
}
.btn-unlink {
  margin-top: 6px; background: transparent; border: 1px solid #fcc;
  color: #c33; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; cursor: pointer;
}
.btn-unlink:hover { background: #fee; }
@media (max-width: 640px) {
  .link-form { flex-direction: column; }
  .linked-grid { grid-template-columns: 1fr; }
}

/* Sold status tag on product cards */
.sold-tag {
  background: #fde8e8;
  color: #c0392b;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

/* Ad tracking (廣告中) */
.ad-tag {
  background: #fff3d6;
  color: #b8860b;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.btn-ad-filter {
  background: #fff3d6;
  color: #b8860b;
  border: 1px solid #e6c96a;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ad-filter:hover { background: #ffe9b3; }
.ad-quick-toggle {
  border: 1px solid #ddd;
  background: #f7f7f7;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 6px;
  opacity: 0.55;
}
.ad-quick-toggle.on {
  background: #ffe9b3;
  border-color: #e6c96a;
  opacity: 1;
}
.ad-quick-toggle:hover { opacity: 1; }
.ad-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ad-toggle {
  border: 1.5px dashed #b8860b;
  background: #fffdf5;
  color: #b8860b;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.ad-toggle.on {
  border-style: solid;
  background: #ffe9b3;
}
.ad-toggle-hint {
  font-size: 12px;
  color: #8a6d9b;
  opacity: 0.85;
}
