* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f1f5f9;
  color: #1f2937;
  line-height: 1.5;
}

a { color: #2563eb; text-decoration: none; }

/* topbar */
.topbar {
  background: #0f172a;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.topbar .brand { font-weight: 800; font-size: 20px; letter-spacing: -0.3px; }
.topbar .right { display: flex; gap: 14px; align-items: center; }
.topbar .who { font-size: 14px; color: #cbd5e1; }

/* buttons & pills */
.btn {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: transform .12s, background .12s, box-shadow .12s;
}
.btn:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(37,99,235,.25); }
.btn.ghost { background: transparent; border: 1px solid #475569; color: #e2e8f0; }
.btn.ghost:hover { background: rgba(255,255,255,.08); }
.btn.green { background: #16a34a; }
.btn.green:hover { background: #15803d; }
.btn.red { background: #dc2626; }
.btn.sm { padding: 7px 14px; font-size: 13px; }

.pill {
  background: #1e40af;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.pill.green { background: #16a34a; }

input, select {
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
}
input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* container */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }

/* hero */
.hero {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 55%, #3b82f6 100%);
  color: #fff;
  padding: 56px 24px 64px;
  text-align: center;
  border-bottom: 1px solid #dbeafe;
}
.hero h1 { font-size: 38px; font-weight: 800; margin-bottom: 12px; letter-spacing: -1px; }
.hero p { font-size: 17px; color: #dbeafe; max-width: 560px; margin: 0 auto 24px; }
.searchbar { max-width: 540px; margin: 0 auto; }
.searchbar input {
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}

/* category tabs */
.tabs {
  margin-bottom: 22px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 12px;
}
.tabs-inner { display: flex; gap: 10px; flex-wrap: wrap; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.tab:hover { border-color: #2563eb; color: #2563eb; }
.tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.tab .count { font-weight: 700; font-size: 12px; opacity: .75; }
.tab.active .count { color: #dbeafe; opacity: 1; }

/* results */
.result-bar { font-size: 14px; color: #64748b; margin-bottom: 14px; }
.empty { color: #64748b; padding: 40px 0; text-align: center; font-size: 15px; }

/* product grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.prod {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  display: flex;
  flex-direction: column;
  transition: transform .18s, box-shadow .18s;
  border: 1px solid #e2e8f0;
}
.prod:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,.12); }
.prod .img-wrap { height: 180px; background: #f8fafc; overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative; }
.prod img { width: 100%; height: 100%; object-fit: cover; }
.img-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.img-ph span { font-size: 32px; font-weight: 800; color: rgba(0,0,0,.18); }
.prod .body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.prod .cat-tag {
  display: inline-block;
  width: fit-content;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #2563eb;
  background: #eff6ff;
  padding: 3px 8px;
  border-radius: 6px;
}
.prod .name { font-weight: 700; font-size: 16px; color: #0f172a; margin-top: 2px; }
.prod .spec { color: #64748b; font-size: 13px; min-height: 20px; }
.prod .price { font-weight: 800; font-size: 18px; color: #16a34a; margin-top: 2px; }
.prod .foot { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.prod .qty { display: flex; align-items: center; border: 1px solid #cbd5e1; border-radius: 10px; overflow: hidden; }
.prod .qty button {
  width: 32px; height: 34px; border: none; background: #f1f5f9; color: #334155; font-size: 16px; cursor: pointer;
}
.prod .qty button:hover { background: #e2e8f0; }
.prod .qty input { width: 42px; text-align: center; border: none; border-left: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0; padding: 0; height: 34px; }

/* cart */
.cart { position: fixed; right: 20px; bottom: 20px; z-index: 90; }
.cartbox {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px;
  width: 300px;
  box-shadow: 0 12px 36px rgba(0,0,0,.16);
}
.carthead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.carthead b { font-size: 16px; }
.carthead .clear { background: none; border: none; color: #94a3b8; font-size: 12px; cursor: pointer; }
.carthead .clear:hover { color: #dc2626; }
.cartline { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
.cartline .info { display: flex; flex-direction: column; gap: 2px; }
.cartline .n { color: #334155; font-weight: 600; }
.cartline .q { color: #64748b; font-size: 12px; }
.cartline .price { font-weight: 700; color: #0f172a; white-space: nowrap; }
.carttotal { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 14px; font-size: 15px; }
.carttotal b { font-size: 18px; color: #0f172a; }
.cartbox .btn { width: 100%; }

/* dashboard / balance */
.dash-row { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 32px; }
.card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  border: 1px solid #e2e8f0;
  flex: 1;
  min-width: 300px;
}
.card.wide { flex: 2; min-width: 360px; }
.section-title { font-size: 17px; font-weight: 700; color: #0f172a; margin-bottom: 14px; }
.metric { font-size: 15px; margin-bottom: 6px; color: #475569; }
.metric b { color: #0f172a; font-size: 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px; border-bottom: 1px solid #f1f5f9; }
th { color: #64748b; font-weight: 700; }

/* toast */
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  z-index: 99;
  opacity: 0;
  transition: opacity .3s;
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modalbox {
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  width: 360px;
  max-width: 92vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modalbox .close {
  text-align: right;
  margin-top: 14px;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}
.modalbox .close:hover { color: #64748b; }

/* footnote */
.footnote { text-align: center; color: #94a3b8; font-size: 13px; margin-top: 40px; }

/* responsive */
@media (max-width: 640px) {
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 15px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .prod .img-wrap { height: 150px; }
  .tabs-inner { gap: 8px; }
  .tab { padding: 7px 12px; font-size: 12px; }
  .cartbox { width: calc(100vw - 32px); right: 16px; bottom: 16px; }
}

/* product card clickable -> detail */
.prod { cursor: pointer; }
.prod .img-wrap { cursor: pointer; }
.prod .img-wrap .more {
  position: absolute; right: 8px; bottom: 8px; background: rgba(15,23,42,.72);
  color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; pointer-events: none;
}

/* gallery modal */
.modal.gal { background: rgba(0,0,0,.88); z-index: 300; }
.galbox { position: relative; display: flex; flex-direction: column; align-items: center; max-width: 92vw; }
.galmain img { max-width: 92vw; max-height: 70vh; object-fit: contain; border-radius: 10px; background: #fff; }
.galthumbs { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; max-width: 92vw; }
.gthumb { width: 64px; height: 64px; object-fit: cover; border-radius: 7px; cursor: pointer; border: 2px solid transparent; }
.gthumb.active { border-color: #16a34a; }
.galclose {
  position: absolute; top: -40px; right: 0; background: #fff; border: none; font-size: 22px;
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; line-height: 1; padding: 0;
}

/* product detail modal */
.modal.detail { background: rgba(0,0,0,.6); z-index: 300; }
.detailbox {
  position: relative; background: #fff; border-radius: 16px; padding: 22px;
  width: min(880px, 94vw); max-height: 92vh; overflow-y: auto;
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px;
}
.detailbox .galclose { position: absolute; top: 12px; right: 12px; background: #f1f5f9; color:#0f172a; z-index: 2; }
.dgalmain { background: #f8fafc; border-radius: 12px; min-height: 260px; display: flex; align-items: center; justify-content: center; padding: 10px; }
.dgalmain img { max-width: 100%; max-height: 60vh; object-fit: contain; border-radius: 10px; }
.dinfo { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.dinfo .name { font-size: 22px; font-weight: 700; }
.dinfo .spec { color: #475569; }
.dinfo .price { font-size: 24px; font-weight: 700; color: #16a34a; }
.pdesc { white-space: pre-wrap; line-height: 1.6; color: #334155; background: #f8fafc; border-radius: 10px; padding: 12px; margin-top: 4px; }
.coasec { margin-top: 6px; }
.coasec h4 { margin: 0 0 8px; font-size: 15px; color: #0f172a; }
.coalist { display: flex; gap: 10px; flex-wrap: wrap; }
.coaitem { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: #334155; font-size: 12px; width: 84px; }
.coaitem img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid #e2e8f0; }
.coaitem.pdf { justify-content: center; height: 84px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fef2f2; }
.coaitem .pdficon { font-weight: 700; color: #dc2626; font-size: 14px; }
@media (max-width: 680px) { .detailbox { grid-template-columns: 1fr; } }

