:root {
  --bg: #faf7f9;
  --card: #ffffff;
  --ink: #2b2330;
  --muted: #8a8190;
  --accent: #e84d8a;
  --accent-soft: #fce4ef;
  --line: #efe8ee;
  --shadow: 0 2px 14px rgba(120, 70, 100, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

/* the [hidden] attribute must win over component display rules
   (.login-overlay/.modal use display:flex, which would otherwise override it) */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.brand small { color: var(--muted); font-weight: 500; font-size: 12px; }

.search {
  flex: 1;
  min-width: 180px;
  max-width: 380px;
  position: relative;
}
.search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.search::before {
  content: "🔍";
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.6;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 60px;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 26px;
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; overflow: visible; }
  .cat-list { display: flex; flex-wrap: wrap; gap: 8px; }
}

.sidebar {
  position: sticky;
  top: 78px;
  align-self: start;
  /* scroll the sidebar itself when the category list is taller than the viewport */
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}
.sidebar h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 4px 0 12px;
}
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li {
  padding: 9px 13px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  transition: background 0.15s;
}
.cat-list li:hover { background: #fff; }
.cat-list li.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.cat-list li .count {
  font-size: 12px;
  opacity: 0.7;
  background: rgba(0,0,0,0.06);
  padding: 1px 8px;
  border-radius: 999px;
}
.cat-list li.active .count { background: rgba(255,255,255,0.25); }

/* grouped sidebar: 全部 / 大类 / 子目录 */
.cat-list li.cat-all { font-weight: 700; }
.cat-list li.cat-group {
  font-weight: 700;
  font-size: 13px;
  margin-top: 10px;
  color: var(--ink);
}
.cat-list li.cat-group::before {
  content: "";
  width: 6px; height: 6px; border-radius: 2px;
  background: var(--accent);
  margin-right: 8px;
  flex: 0 0 auto;
}
.cat-list li.cat-group > span:first-child { flex: 1; }
.cat-list li.cat-sub {
  font-size: 13px;
  color: var(--muted);
  padding-left: 26px;
  margin-bottom: 2px;
}
.cat-list li.cat-sub:hover { color: var(--ink); }

/* ---------- Grid ---------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar h2 { margin: 0; font-size: 22px; }
.toolbar .result-count { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(120, 70, 100, 0.16);
}
.card .thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #fff;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.card-special { border-color: var(--accent); box-shadow: 0 2px 14px rgba(232, 77, 138, 0.18); }
.card .thumb .badge {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.card-special .price { color: var(--accent); font-weight: 600; font-size: 13px; }
.card .thumb img {
  width: 100%; height: 100%;
  object-fit: contain;   /* show the whole product image (irregular ratios, e.g. LUATEK) */
}
.card .body { padding: 11px 13px 14px; }
.card .code {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.card .name {
  font-size: 12px;
  color: var(--muted);
  margin: 3px 0 9px;
  min-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card .price {
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
}
.card .price span { font-size: 11px; color: var(--muted); font-weight: 500; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
}

/* ---------- Detail ---------- */
.detail-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 26px 20px 70px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
}
.back:hover { color: var(--accent); }
.detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 34px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--shadow);
}
@media (max-width: 720px) { .detail { grid-template-columns: 1fr; } }
.detail .photo {
  border-radius: 14px;
  overflow: hidden;
  background: #f3eef2;
}
.detail .photo img { width: 100%; display: block; }
.detail .info h1 { margin: 4px 0 6px; font-size: 26px; }
.detail .info .cat-tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.detail .info .big-price {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  margin: 6px 0 20px;
}
.detail .info .big-price span { font-size: 14px; color: var(--muted); font-weight: 500; }
.spec {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.spec td {
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.spec td.k { color: var(--muted); width: 92px; }
.desc {
  margin-top: 22px;
}
.desc h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--ink);
}
.desc pre,
.desc-body {
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.9;
  color: #4a424f;
  background: #faf7f9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 15px;
  max-height: 320px;
  overflow: auto;
}
.note {
  margin-top: 22px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* whole-catalog gallery (整本 PPT) */
.catalog-pages { margin-top: 26px; }
.catalog-pages h3 {
  font-size: 15px;
  margin: 0 0 14px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}
.catalog-pages .pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.catalog-pages .pages img {
  width: 100%;
  max-width: 780px;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: #fff;
}

.site-footer {
  margin-top: 50px;
  background: linear-gradient(160deg, #fff 0%, #fdf4f9 100%);
  border-top: 1px solid var(--line);
}
.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 36px;
  flex-wrap: wrap;
}
.footer-brand { max-width: 360px; }
.footer-brand .brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.footer-brand .brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.footer-brand .brand small { color: var(--muted); font-weight: 500; font-size: 12px; }
.footer-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}

.footer-contact {
  display: flex;
  align-items: center;
  gap: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 20px 16px 16px;
  box-shadow: var(--shadow);
}
.qr-card {
  width: 116px;
  height: 116px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.qr-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.contact-info { display: flex; flex-direction: column; gap: 4px; }
.contact-label {
  display: inline-block;
  align-self: flex-start;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.contact-name { font-size: 19px; font-weight: 800; color: var(--ink); }
.contact-hint { font-size: 12px; color: var(--muted); line-height: 1.6; max-width: 190px; }

.footer-bottom {
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 16px 20px;
}

@media (max-width: 620px) {
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 24px; }
  .footer-contact { width: 100%; }
}

/* ---------- Buttons (shared) ---------- */
.btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(0.95); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: #fff; color: #d23b54; border-color: #f3c4cd; }
.btn.danger:hover { background: #fff0f2; }
.btn.sm { padding: 5px 12px; font-size: 13px; }

/* ---------- Login overlay ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: linear-gradient(160deg, #fdf2f8, #f3eef8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(120, 70, 100, 0.16);
  padding: 34px 30px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.login-card .dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
  margin-bottom: 14px;
}
.login-card h2 { margin: 0 0 4px; font-size: 21px; }
.login-card p { margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.login-card input {
  width: 100%;
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  margin-bottom: 14px;
}
.login-card input:focus { border-color: var(--accent); }
.login-card .btn { width: 100%; padding: 11px; }
.login-card .form-err { color: #d23b54; font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- Admin ---------- */
.admin-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 60px;
}
.select {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  padding: 8px 14px;
  color: var(--ink);
  outline: none;
  cursor: pointer;
}
.select:focus { border-color: var(--accent); }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 14px;
}
.admin-table th, .admin-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.admin-table thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: #fdfbfc;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: #fdf6fa; }
.admin-table .cell-name { color: var(--muted); }
.admin-table .col-img { width: 56px; }
.admin-table .col-img img {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: #f3eef2;
  display: block;
}
.admin-table .no-img {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 8px;
  background: #f3eef2;
  color: var(--muted);
  font-size: 11px;
}
.admin-table .col-price { color: var(--accent); font-weight: 700; white-space: nowrap; }
.admin-table .col-act { width: 1%; white-space: nowrap; text-align: right; }
.admin-table .col-act .btn { margin-left: 6px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(43, 35, 48, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 18px;
  z-index: 50;
  overflow: auto;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  padding: 24px 26px 22px;
  box-shadow: 0 18px 50px rgba(60, 30, 50, 0.28);
}
.modal-card h3 { margin: 0 0 18px; font-size: 19px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input,
.form-grid select,
.form-grid textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  background: #fff;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus { border-color: var(--accent); }
.form-grid textarea { resize: vertical; }
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.form-err { color: #d23b54; font-size: 13px; margin-right: auto; }

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .admin-table .col-img, .admin-table thead .col-img { display: none; }
}
