  :root {
    --bg: #f6f7fb;
    --card: #ffffff;
    --text: #1a1d29;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  }

  * { box-sizing: border-box; }
  body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
  }

  header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px;
  }

  .header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    flex-wrap: wrap;
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 20px;
  }
  .logo-badge {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: 16px;
  }

  .search-wrap {
    flex: 1;
    min-width: 220px;
    max-width: 420px;
    position: relative;
  }
  .search-wrap input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg);
    outline: none;
    transition: border-color .15s;
  }
  .search-wrap input:focus { border-color: var(--accent); background: var(--card); }
  .search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-size: 14px; pointer-events: none;
  }

  .controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
  }

  select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
    outline: none;
  }
  select:focus { border-color: var(--accent); }

  .result-count {
    font-size: 13px;
    color: var(--muted);
    margin-left: auto;
  }

  main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
  }

  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
  }

  .card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    display: flex;
    flex-direction: column;
  }
  .card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
  }
  .card-img {
    width: 100%;
    height: 170px;
    object-fit: contain;
    background: #fafafa;
    padding: 10px;
  }
  .card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
  }
  .card-category {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--accent);
    font-weight: 600;
  }
  .card-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    min-height: 39px;
  }
  .card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 6px;
  }
  .card-price { font-weight: 700; font-size: 16px; }
  .card-rating {
    font-size: 12.5px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 3px;
  }
  .badge-stock {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    width: fit-content;
  }
  .badge-in { background: #dcfce7; color: var(--success); }
  .badge-low { background: #fef3c7; color: #b45309; }
  .badge-out { background: #fee2e2; color: var(--danger); }

  /* Skeleton loading */
  .skeleton { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .skeleton-img { width: 100%; height: 170px; background: linear-gradient(90deg,#eee 25%,#f5f5f5 37%,#eee 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
  .skeleton-line { height: 12px; margin: 14px; border-radius: 4px; background: linear-gradient(90deg,#eee 25%,#f5f5f5 37%,#eee 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
  .skeleton-line.short { width: 40%; }
  @keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

  /* States */
  .state-box {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
  }
  .state-box .icon { font-size: 40px; margin-bottom: 10px; }
  .state-box h3 { margin: 0 0 6px; color: var(--text); font-size: 17px; }
  .retry-btn, .load-more-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 14px;
    transition: background .15s;
  }
  .retry-btn:hover, .load-more-btn:hover { background: var(--accent-hover); }

  .load-more-wrap { display: flex; justify-content: center; margin-top: 28px; }
  .load-more-btn:disabled { opacity: .6; cursor: not-allowed; }

  /* Modal */
  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,17,24,.55);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    z-index: 100;
    animation: fadeIn .15s ease;
  }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  .modal {
    background: var(--card);
    border-radius: 16px;
    max-width: 780px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
  }
  .modal-close {
    position: absolute; top: 14px; right: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    width: 34px; height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    z-index: 2;
  }
  .modal-content { display: flex; flex-wrap: wrap; }
  .modal-gallery { flex: 1 1 320px; padding: 24px; background: #fafafa; }
  .modal-main-img {
    width: 100%; height: 280px; object-fit: contain; border-radius: 10px; background: white; margin-bottom: 10px;
  }
  .modal-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
  .modal-thumbs img {
    width: 54px; height: 54px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border);
    background: white; cursor: pointer; padding: 3px;
  }
  .modal-thumbs img.active { border-color: var(--accent); border-width: 2px; }
  .modal-info { flex: 1 1 320px; padding: 24px; }
  .modal-info h2 { margin: 6px 0 4px; font-size: 22px; }
  .modal-brand { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }
  .modal-price-row { display: flex; align-items: baseline; gap: 10px; margin: 12px 0; }
  .modal-price { font-size: 26px; font-weight: 800; }
  .modal-discount { color: var(--success); font-size: 13.5px; font-weight: 600; }
  .modal-desc { font-size: 14px; line-height: 1.6; color: #374151; margin-bottom: 16px; }
  .modal-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 13.5px; margin-bottom: 16px; }
  .modal-meta div { background: var(--bg); padding: 8px 10px; border-radius: 8px; }
  .modal-meta strong { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; margin-bottom: 2px; }
  .modal-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
  .modal-tags span { background: #eef2ff; color: var(--accent); font-size: 12px; padding: 3px 10px; border-radius: 999px; }
  .reviews h4 { font-size: 14px; margin-bottom: 8px; }
  .review-item { border-top: 1px solid var(--border); padding: 10px 0; font-size: 13px; }
  .review-item .rname { font-weight: 600; }
  .review-item .rrating { color: #f59e0b; }
  .review-item .rcomment { color: var(--muted); margin-top: 2px; }

  footer {
    text-align: center; padding: 20px; color: var(--muted); font-size: 12.5px;
  }

  @media (max-width: 640px) {
    .header-top { flex-direction: column; align-items: stretch; }
    .search-wrap { max-width: none; }
    .result-count { margin-left: 0; width: 100%; }
    .modal-content { flex-direction: column; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .card-img { height: 130px; }
  }
