* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  padding-bottom: 80px;
}
header {
  background: #1f2937;
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}
header h1 { font-size: 20px; font-weight: 600; }
.updated { font-size: 12px; opacity: 0.6; }

.filters {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 12px 24px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  z-index: 10;
  flex-wrap: wrap;
}
.filters select, .filters input, .filters button {
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
}
.filters input { flex: 1; min-width: 200px; }
.filters .stat { font-size: 13px; color: #6b7280; margin-left: auto; }
.filters button.primary {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
  cursor: pointer;
}
.filters button.primary:hover { background: #2563eb; }
.filters button.danger {
  background: #fff;
  color: #ef4444;
  border-color: #ef4444;
  cursor: pointer;
}
.filters button.danger:hover { background: #fef2f2; }

.flag-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255,255,255,0.9);
  border: 1px solid #e5e7eb;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  transition: opacity 0.15s, background 0.15s;
  z-index: 5;
}
.card:hover .flag-btn { opacity: 1; }
.flag-btn:hover { background: #fef2f2; border-color: #ef4444; }
.card .multi-badge { right: 38px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 16px 24px;
}
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59,130,246,0.15);
}
.card.selected {
  border-color: #10b981;
  background: #f0fdf4;
}
.card .name {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
  line-height: 1.4;
  word-break: break-all;
}
.card .price {
  font-size: 22px;
  font-weight: 700;
  color: #3b82f6;
  margin-bottom: 10px;
}
.card .price small { font-size: 12px; color: #6b7280; font-weight: 400; }
.card .meta {
  font-size: 12px;
  color: #4b5563;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.card .meta span { display: flex; align-items: center; gap: 6px; }
.card .tag {
  display: inline-block;
  background: #eff6ff;
  color: #1e40af;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}
.card .card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 6px;
}
.card .src-tag, .card .type-tag {
  display: inline-block;
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.card .type-tag { padding: 2px 6px; font-weight: 600; }

/* === 公開模式：隱藏敏感欄位 / 按鈕 === */
body.public-mode #companySel,
body.public-mode #flagBtn,
body.public-mode #clipBtn,
body.public-mode #highConfTog,
body.public-mode #highConfTog + span,
body.public-mode label:has(#highConfTog),
body.public-mode #clipboard,
body.public-mode .card { cursor: default; }
body.public-mode #companySel,
body.public-mode #flagBtn,
body.public-mode #clipBtn,
body.public-mode label:has(#highConfTog) { display: none !important; }
body.public-mode .card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); border-color: #e5e7eb; }
.card .multi-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.clipboard {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 360px;
  background: #fff;
  border-left: 2px solid #3b82f6;
  display: flex;
  flex-direction: column;
  z-index: 20;
  box-shadow: -4px 0 16px rgba(0,0,0,0.1);
}
.clipboard.hidden { display: none; }
.clipboard header {
  background: #3b82f6;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.clipboard header h2 { font-size: 16px; }
.clipboard header button {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
}
.clipboard header button:hover { background: rgba(255,255,255,0.25); }
#clipList { list-style: none; overflow-y: auto; flex: 1; padding: 8px; }
#clipList li {
  padding: 8px 10px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
#clipList li button {
  background: none; border: none; color: #ef4444; cursor: pointer; font-size: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal.hidden { display: none; }
.modal-content {
  background: #fff;
  border-radius: 12px;
  max-width: 720px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: #f3f4f6;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}
.modal h2 { font-size: 20px; margin-bottom: 12px; }
.modal table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}
.modal th, .modal td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
}
.modal th { background: #f9fafb; font-weight: 600; }
.modal .summary {
  margin-top: 12px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 6px;
  font-size: 13px;
  color: #4b5563;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 640px) {
  .clipboard { width: 100%; }
  .cards { padding: 12px; }
}
