* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: #222; background: #fafafa; }
header { background: #fff; padding: 14px 24px; border-bottom: 1px solid #eee; position: sticky; top: 0; z-index: 10; }
header h1 { margin: 0 0 8px; font-size: 20px; }
#search { width: 100%; max-width: 480px; padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
#stats { font-size: 12px; color: #888; margin-top: 4px; }
main { display: flex; min-height: calc(100vh - 100px); }
#sidebar { width: 220px; background: #fff; border-right: 1px solid #eee; padding: 16px; position: sticky; top: 100px; align-self: flex-start; max-height: calc(100vh - 100px); overflow: auto; }
#sidebar h3 { margin: 0 0 8px; font-size: 14px; color: #555; }
#cat-list { list-style: none; padding: 0; margin: 0; }
#cat-list li { padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; }
#cat-list li:hover { background: #f0f4ff; }
#cat-list li.active { background: #2864e3; color: #fff; }
#cat-list .count { color: #999; font-size: 11px; margin-left: 4px; }
#cat-list li.active .count { color: #cfe0ff; }
#grid { flex: 1; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); cursor: pointer; transition: transform .12s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.card .body { padding: 10px 12px; }
.card .title { font-size: 13px; font-weight: 600; line-height: 1.3; height: 34px; overflow: hidden; }
.card .cat { font-size: 11px; color: #999; margin: 4px 0 6px; }
.card .prices { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.card .sale { color: #e23; font-size: 16px; font-weight: 700; }
.card .profit { color: #0a7d32; font-size: 12px; font-weight: 600; }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
#modal.hidden { display: none; }
.modal-card { background: #fff; border-radius: 10px; max-width: 960px; width: 94%; max-height: 90vh; overflow: auto; position: relative; padding: 16px; }
.close { position: absolute; right: 10px; top: 4px; background: none; border: 0; font-size: 28px; cursor: pointer; z-index: 1; }
.modal-top { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #f5f5f5; border-radius: 6px; }
.thumbs { display: flex; gap: 4px; padding: 6px 0; overflow-x: auto; }
.thumbs img { width: 56px; height: 56px; object-fit: cover; border: 2px solid transparent; border-radius: 4px; cursor: pointer; }
.thumbs img.active { border-color: #2864e3; }
.info { padding: 4px 0; }
.info h2 { margin: 0 0 6px; font-size: 18px; }
.info .sku { font-size: 13px; color: #555; font-weight: 600; margin-bottom: 4px; }
.info .sku span { color: #2864e3; }
.info .cat { color: #888; font-size: 12px; margin-bottom: 10px; }
.info .price { margin: 10px 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.info .price .sale { color: #e23; font-size: 24px; font-weight: 700; }
.info .price .profit { color: #0a7d32; font-size: 15px; font-weight: 700; }
.info .stock { font-size: 12px; color: #080; margin-bottom: 12px; }
.spec-wrap h3, .desc-wrap h3 { font-size: 14px; color: #333; margin: 8px 0; border-bottom: 2px solid #2864e3; padding-bottom: 4px; }
.spec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec-table th, .spec-table td { border: 1px solid #e5e5e5; padding: 6px 10px; text-align: left; vertical-align: top; }
.spec-table th { background: #f5f8ff; color: #444; white-space: nowrap; width: 38%; font-weight: 600; }
.desc-wrap { margin-top: 8px; }
.description { font-size: 13px; color: #444; overflow-x: auto; }
.description img { max-width: 100%; height: auto; display: block; margin: 8px 0; }
.description table { border-collapse: collapse; font-size: 12px; margin: 8px 0; }
.description table td, .description table th { border: 1px solid #ddd; padding: 4px 8px; }
.description ul, .description ol { padding-left: 20px; }
@media (max-width: 720px) {
  main { flex-direction: column; }
  #sidebar { width: 100%; position: static; max-height: none; }
  .modal-top { grid-template-columns: 1fr; }
}
