
:root{
  --bg:#f7f9fc;
  --card:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:#dfe5ec;
  --soft:#f5f7fa;
  --soft2:#eef2f6;
  --accent:#2563eb;
  --accent-soft:#eff6ff;
  --price:#ef233c;
  --shadow:0 4px 14px rgba(15,23,42,.05);
}

*{box-sizing:border-box}

html,body{
  margin:0;
  padding:0;
  background:var(--bg);
  color:var(--text);
  font-family:Arial,Helvetica,sans-serif;
  -webkit-font-smoothing:antialiased;
}

body.dark{
  --bg:#111827;
  --card:#182235;
  --text:#f8fafc;
  --muted:#a8b1c0;
  --line:#2b3950;
  --soft:#1d2a40;
  --soft2:#223149;
  --accent:#60a5fa;
  --accent-soft:#172554;
  --price:#fb7185;
  --shadow:none;
}

.page{
  width:min(1180px,calc(100% - 28px));
  margin:0 auto;
  padding:20px 0 30px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:18px;
  margin-bottom:12px;
}

.topbar h1{
  margin:0;
  font-size:24px;
  line-height:1.15;
  font-weight:700;
}

.sync-status{
  margin-top:5px;
  color:var(--muted);
  font-size:12px;
}

.theme-toggle{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  white-space:nowrap;
  padding-top:4px;
}

.toolbar{
  position:sticky;
  top:0;
  z-index:50;
  padding:9px 0 11px;
  margin-bottom:12px;
  background:rgba(247,249,252,.96);
  backdrop-filter:blur(8px);
  border-bottom:1px solid var(--line);
}

body.dark .toolbar{
  background:rgba(17,24,39,.96);
}

.search-wrap{
  position:relative;
}

.search-input{
  width:100%;
  height:44px;
  padding:0 14px;
  border:1px solid var(--line);
  border-radius:10px;
  outline:none;
  background:var(--card);
  color:var(--text);
  font-size:14px;
  box-shadow:var(--shadow);
}

.search-input:focus{
  border-color:var(--accent);
}

.suggestions{
  display:none;
  position:absolute;
  top:49px;
  left:0;
  right:0;
  z-index:80;
  max-height:320px;
  overflow:auto;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:10px;
  box-shadow:0 12px 30px rgba(15,23,42,.14);
}

.suggestions.show{
  display:block;
}

.suggestion-item{
  width:100%;
  border:0;
  border-bottom:1px solid var(--line);
  background:transparent;
  color:var(--text);
  text-align:left;
  padding:11px 13px;
  font-size:14px;
  cursor:pointer;
}

.suggestion-item:last-child{
  border-bottom:0;
}

.suggestion-item:active,
.suggestion-item:hover{
  background:var(--soft);
}

.only-priced{
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin-top:8px;
  color:var(--muted);
  font-size:12px;
}

.price-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
  align-items:start;
}

.column{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.product-card{
  overflow:hidden;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:12px;
  box-shadow:var(--shadow);
  scroll-margin-top:90px;
}

.product-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  cursor:pointer;
  user-select:none;
}

.product-name{
  font-size:16px;
  font-weight:700;
}

.chevron{
  font-size:16px;
  color:var(--muted);
  transition:transform .18s ease;
}

.product-card.collapsed .chevron{
  transform:rotate(-90deg);
}

.product-card.collapsed .product-body{
  display:none;
}

.product-body{
  border-top:1px solid var(--line);
}

.variant-row{
  display:grid;
  grid-template-columns:86px 1fr;
  border-top:1px solid var(--line);
}

.variant-row:first-child{
  border-top:0;
}

.storage-wrap{
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:10px 6px;
  background:var(--soft);
  border-right:1px solid var(--line);
}

.storage-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:60px;
  padding:6px 8px;
  border:1px solid #9fc0ff;
  border-radius:9px;
  color:var(--accent);
  background:var(--accent-soft);
  font-size:11px;
  font-weight:700;
}

.colors-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
}

.price-cell{
  min-height:62px;
  padding:9px 10px;
  border-right:1px solid var(--line);
  border-bottom:1px solid var(--line);
}

.price-cell:nth-child(3n){
  border-right:0;
}

.color-line{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:12px;
}

.color-dot{
  width:8px;
  height:8px;
  flex:0 0 8px;
  border-radius:50%;
  border:1px solid rgba(0,0,0,.08);
}

.price{
  display:block;
  margin-top:5px;
  color:var(--price);
  font-size:15px;
  font-weight:700;
}

.loading,.error-box{
  grid-column:1/-1;
  padding:30px 18px;
  text-align:center;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:12px;
  color:var(--muted);
}

.floating-search{
  display:none;
  position:fixed;
  right:16px;
  bottom:22px;
  z-index:70;
  width:48px;
  height:48px;
  border:0;
  border-radius:50%;
  background:var(--accent);
  color:#fff;
  font-size:26px;
  line-height:1;
  box-shadow:0 8px 22px rgba(37,99,235,.32);
  cursor:pointer;
}

.footer{
  margin-top:24px;
  text-align:center;
  color:var(--muted);
  font-size:12px;
  line-height:1.5;
}

@media(max-width:900px){
  .page{
    width:min(100% - 18px,760px);
  }

  .price-grid{
    grid-template-columns:1fr;
    gap:10px;
  }

  .column{
    gap:10px;
  }

  .floating-search{
    display:block;
  }

  .product-card{
    border-radius:10px;
  }

  .product-header{
    padding:12px 13px;
  }

  .product-name{
    font-size:15px;
  }

  /* Mobile: mặc định chỉ hiện tên máy */
  .product-card.mobile-default-collapsed .product-body{
    display:none;
  }

  .product-card.mobile-default-collapsed .chevron{
    transform:rotate(-90deg);
  }

  .product-card.mobile-default-collapsed.mobile-open .product-body{
    display:block;
  }

  .product-card.mobile-default-collapsed.mobile-open .chevron{
    transform:none;
  }
}

@media(max-width:560px){
  .page{
    width:100%;
    padding:10px 8px 22px;
  }

  .topbar h1{
    font-size:19px;
    max-width:72vw;
  }

  .toolbar{
    padding-top:5px;
  }

  .search-input{
    height:42px;
  }

  .variant-row{
    grid-template-columns:76px 1fr;
  }

  .storage-wrap{
    padding:8px 5px;
  }

  .storage-badge{
    min-width:56px;
    padding:5px 6px;
    font-size:11px;
  }

  .colors-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .price-cell{
    min-height:58px;
    padding:8px 9px;
  }

  .price-cell:nth-child(3n){
    border-right:1px solid var(--line);
  }

  .price-cell:nth-child(2n){
    border-right:0;
  }

  .color-line{
    font-size:11px;
  }

  .price{
    font-size:14px;
  }

  .suggestions{
    max-height:260px;
  }
}


/* ===== Footer nội bộ ===== */
.footer{
  margin-top:28px;
  padding:22px 12px 10px;
  text-align:center;
  color:var(--muted);
  font-size:12px;
  line-height:1.5;
}

.footer-divider{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  margin-bottom:14px;
}

.footer-line{
  display:block;
  height:1px;
  flex:1;
  max-width:360px;
  background:var(--line);
}

.footer-shield{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:28px;
  height:28px;
  border:2px solid var(--accent);
  border-radius:9px 9px 12px 12px;
  color:var(--accent);
  font-size:15px;
  font-weight:700;
  line-height:1;
}

.footer-note{
  font-size:13px;
  color:var(--muted);
  margin-bottom:10px;
}

.footer-credit{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  flex-wrap:wrap;
  font-size:13px;
  color:var(--muted);
}

.footer-credit strong{
  color:var(--accent);
  font-weight:700;
}

.footer-sep{
  opacity:.6;
}

@media(max-width:560px){
  .footer{
    padding-left:8px;
    padding-right:8px;
  }

  .footer-note{
    font-size:12px;
  }

  .footer-credit{
    gap:8px;
    font-size:12px;
  }

  .footer-line{
    max-width:120px;
  }
}
/* ===== Load nhanh / giữ dữ liệu cũ khi refresh ===== */
.loading{
  position:relative;
  overflow:hidden;
}
.loading::after{
  content:"";
  position:absolute;
  inset:0;
  transform:translateX(-100%);
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.4),transparent);
  animation:priceShimmer 1.2s infinite;
}
@keyframes priceShimmer{
  100%{transform:translateX(100%)}
}


.price.no-price{
  color:var(--muted);
  font-weight:600;
}
