:root {
  color-scheme: light;
  --ink: #182433;
  --muted: #667382;
  --subtle: #8a97a6;
  --line: #dce3ea;
  --line-soft: #eef2f6;
  --surface: #ffffff;
  --page: #f5f7fb;
  --header: #f8fafc;
  --accent: #206bc4;
  --accent-dark: #1d5fac;
  --accent-soft: #e8f1fb;
  --danger: #d63939;
  --shadow: 0 1px 2px rgba(24, 36, 51, 0.04), 0 8px 24px rgba(24, 36, 51, 0.06);
  --radius: 6px;
}

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-size: 14px;
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: saturate(180%) blur(10px);
}

h1 {
  margin: 0;
  color: #111827;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0;
}

p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

button {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08);
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 2px 7px rgba(32, 107, 196, 0.18);
}

button:active { transform: translateY(1px); }

.topActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  white-space: nowrap;
}

#cartBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 21px;
  height: 19px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: white;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

main { padding: 18px 24px 28px; }

#sourceLine[hidden] { display: none; }

.filters {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) repeat(3, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 1px rgba(24, 36, 51, 0.03);
}

label {
  display: grid;
  gap: 6px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
}

input, select {
  height: 38px;
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: var(--radius);
  padding: 0 11px;
  background: white;
  color: var(--ink);
  font-size: 13px;
  outline: 0;
  box-shadow: inset 0 1px 1px rgba(24, 36, 51, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder { color: #9aa6b2; }

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 107, 196, 0.14);
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.summary div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 1px 1px rgba(24, 36, 51, 0.03);
}

.summary strong {
  display: block;
  color: #111827;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0;
}

.summary span {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 600;
}

.tableWrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: calc(100vh - 270px);
  box-shadow: var(--shadow);
  scrollbar-color: #b8c4d2 #f2f5f9;
  scrollbar-width: thin;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1400px;
}

th, td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  font-size: 12.5px;
  color: #243447;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--header);
  color: #3b4856;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  white-space: nowrap;
}

tbody tr {
  background: white;
  transition: background-color 0.12s ease;
}

tbody tr:hover { background: #f8fbff; }
tbody tr:nth-child(even) { background: #fcfdff; }
tbody tr:nth-child(even):hover { background: #f8fbff; }

tbody tr:last-child td { border-bottom: 0; }

td.imageCell {
  width: 120px;
  height: 86px;
  text-align: center;
  background: #fbfcfe;
}

.productImage {
  width: 104px;
  height: 72px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}

.imageButton {
  appearance: none;
  border: 1px solid var(--line);
  background: white;
  padding: 4px;
  width: 114px;
  height: 82px;
  cursor: zoom-in;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: var(--radius);
  box-shadow: none;
}

.imageButton:hover {
  background: white;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 107, 196, 0.1);
}

.imageBadge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 21px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(24, 36, 51, 0.86);
  color: white;
  font-size: 11px;
  line-height: 19px;
  font-weight: 700;
}

.imageModal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 58px 92px 44px;
  background: rgba(15, 23, 42, 0.72);
  user-select: none;
}

.imageModal.open {
  display: flex;
  flex-direction: column;
}

.imageModal img {
  width: min(78vw, 980px);
  height: min(76vh, 760px);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: white;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  padding: 14px;
  -webkit-user-drag: none;
  user-select: none;
}

.imageModal p {
  margin-top: 8px;
  color: white;
  max-width: min(94vw, 900px);
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.galleryCounter {
  margin-top: 4px !important;
  color: #dbeafe !important;
  font-size: 13px;
}

.modalClose {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  background: white;
  color: var(--ink);
  border-color: white;
  box-shadow: var(--shadow);
}

.galleryNav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-size: 40px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.galleryNav:disabled {
  opacity: 0.35;
  cursor: default;
}

.galleryPrev { left: 30px; }
.galleryNext { right: 30px; }

td.code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-weight: 700;
  color: #1f5ea8;
  white-space: nowrap;
}

td.price { text-align: right; white-space: nowrap; }
td.actionCell { text-align: center; white-space: nowrap; }

.addCartBtn {
  min-width: 60px;
  height: 30px;
  padding: 0 10px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.pagination button {
  min-width: 62px;
  background: white;
  color: var(--accent);
  border-color: #cfd8e3;
  box-shadow: none;
}

.pagination button:hover {
  background: var(--accent-soft);
  border-color: #9dc2ef;
  box-shadow: none;
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  background: white;
  color: var(--muted);
}

#pageInfo {
  color: var(--muted);
  font-size: 13px;
  min-width: 112px;
  text-align: center;
}

.pageJump { display: flex; grid-template-columns: none; align-items: center; gap: 6px; }
.pageJump input { width: 76px; height: 34px; }
.hint { min-height: 20px; margin-top: 8px; color: var(--muted); }

.cartPanel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.cartHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--header);
}

.cartHeader h2 {
  margin: 0;
  color: #111827;
  font-size: 17px;
  font-weight: 700;
}

.cartHeader p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.cartActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cartActions button {
  min-width: 84px;
  background: white;
  color: var(--accent);
  border-color: #cfd8e3;
  box-shadow: none;
}

.cartActions button:hover {
  background: var(--accent-soft);
  border-color: #9dc2ef;
  box-shadow: none;
}

.cartTableWrap {
  overflow: auto;
  max-height: 360px;
}

.cartTable th,
.cartTable td {
  height: auto;
  padding: 8px 10px;
}

.cartQty {
  width: 88px;
  height: 32px;
  padding: 0 8px;
  text-align: center;
}

.removeCartBtn {
  min-width: 66px;
  height: 30px;
  background: white;
  color: var(--danger);
  border-color: #f1b8b8;
  box-shadow: none;
}

.removeCartBtn:hover {
  background: #fff5f5;
  color: #b42323;
  border-color: #e58b8b;
}

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 16px; }
  .topActions { width: 100%; justify-content: flex-start; }
  main { padding: 14px 16px 22px; }
  .filters, .summary { grid-template-columns: 1fr; }
  .tableWrap { max-height: none; }
  .cartHeader { align-items: flex-start; flex-direction: column; }
}
