:root {
  --ink: #1d252c;
  --muted: #66727f;
  --paper: #f5f7fa;
  --white: #ffffff;
  --line: #dce2ea;
  --green: #11746f;
  --green-dark: #0b514d;
  --blue: #2f63a3;
  --yellow: #efb34c;
  --shadow: 0 18px 46px rgba(29, 37, 44, .12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

body.dialog-open {
  overflow: hidden;
}

html.auth-locked body {
  overflow: hidden;
}

body.auth-blocked main,
body.auth-blocked .topbar,
body.auth-blocked .back-top,
body.auth-blocked .detail-dialog {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 32, .72);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.auth-card h1 {
  margin-bottom: 0;
  font-size: 34px;
}

.auth-input {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.auth-input input {
  min-height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  letter-spacing: 0;
}

.auth-error {
  margin: 0;
  color: #b42318;
  font-weight: 700;
}

.auth-submit {
  width: 100%;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 112px;
  padding: 0 max(18px, calc((100vw - 1180px) / 2));
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  align-items: center;
  gap: 20px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.brand span:last-child,
.top-contact,
.contact-card a,
.detail-contact {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.brand strong,
.top-contact strong,
.contact-card strong,
.detail-contact strong {
  font-size: 16px;
}

.brand small,
.top-contact small,
.contact-card small,
.detail-contact small,
.stats small,
.stat-link small,
.filter small,
.tag small,
.product-code small,
.detail-code span,
.detail-fields small,
.empty span,
.zh-sub,
.contact-info-panel small,
.factory-placeholder span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.top-contact {
  align-items: center;
  flex: 0 0 auto;
  min-width: 120px;
}

.top-search {
  width: 100%;
  max-width: 620px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: stretch;
  align-self: center;
  justify-self: end;
  margin-left: auto;
}

.top-search-copy {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 100px;
  line-height: 1.1;
  flex: 0 0 auto;
}

.top-search-copy strong {
  font-size: 16px;
}

.top-search-copy small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.top-search input {
  flex: 1 1 auto;
  min-height: 40px;
  width: 100%;
  border-radius: 999px;
  padding-inline: 16px;
}

.top-contact small,
.contact-card small,
.detail-contact small,
.stats small,
.stat-link small {
  color: currentColor;
  opacity: .68;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--green);
  color: var(--white);
}

.top-contact,
.button {
  min-height: 42px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-weight: 800;
}

.top-contact,
.button.ghost {
  background: rgba(17, 116, 111, .08);
  border-color: rgba(17, 116, 111, .22);
}

.button.primary {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}

.hero {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 72px 0 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 34px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 850px;
  margin-bottom: 18px;
  font-size: clamp(40px, 6vw, 78px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 36px;
  letter-spacing: 0;
}

.hero-sub {
  margin-top: -8px;
  font-size: 22px;
}

.lead {
  max-width: 720px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stats div,
.stat-link {
  min-height: 144px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow);
}

.stat-link {
  background: var(--green-dark);
}

.stats strong,
.stat-link strong {
  display: block;
  font-size: 46px;
  line-height: 1;
}

.stat-link strong {
  font-size: 30px;
}

.stats span,
.stat-link span {
  margin-top: 8px;
  color: rgba(255, 255, 255, .74);
}

.stats small,
.stat-link small {
  margin-top: 4px;
}

.products,
.contact {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.catalog-layout {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding-bottom: 56px;
}

.category-section {
  width: auto;
  margin: 0;
  padding: 0;
  position: sticky;
  top: 124px;
  align-self: start;
}

.section-title.compact {
  margin-bottom: 12px;
}

.type-grid {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
}

.type-card {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.type-card.active {
  border-color: var(--green);
  background: rgba(17, 116, 111, .08);
}

.type-card strong {
  font-size: 13px;
  line-height: 1.15;
  letter-spacing: 0;
}

.type-card small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.top-search input {
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
}

.products {
  padding-bottom: 72px;
  padding-top: 18px;
  width: auto;
  margin: 0;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 20px;
}

#resultCount {
  color: var(--muted);
  font-weight: 800;
}

#resultCount span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 220px));
  justify-content: center;
  gap: 16px;
}

.product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 12px 30px rgba(29, 37, 44, .07);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.product-card:focus-visible {
  outline: 3px solid rgba(17, 116, 111, .32);
  outline-offset: 3px;
}

.image-wrap {
  position: relative;
  width: 100%;
  height: 224px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: linear-gradient(180deg, #f7f9fb 0%, #eef1f5 100%);
  overflow: hidden;
  flex: 0 0 auto;
}

.product-card img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
}

.no-image {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  color: var(--muted);
  background: linear-gradient(135deg, #eef1f5, #ffffff);
  font-weight: 800;
}

.no-image strong {
  font-size: 18px;
}

.image-count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-height: 26px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: var(--white);
  background: rgba(29, 37, 44, .74);
  font-size: 12px;
  font-weight: 800;
}

.product-info {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
}

.product-name {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.7em;
  overflow-wrap: anywhere;
}

.product-code {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.4em;
  overflow-wrap: anywhere;
}

.product-code strong {
  margin-right: 6px;
  color: var(--ink);
  font-size: 13px;
}

.product-code small {
  display: inline;
  margin: 0 6px 0 0;
}

.tag {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--blue);
  background: rgba(47, 99, 163, .08);
  font-size: 9px;
  font-weight: 800;
  margin-top: auto;
}

.tag strong {
  font-size: 9px;
  line-height: 1;
}

.empty {
  padding: 34px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.contact {
  width: min(820px, calc(100% - 32px));
  margin: 28px auto 56px;
  padding: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
}

.contact p {
  color: rgba(255, 255, 255, .72);
  line-height: 1.7;
}

.contact-card {
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  background: rgba(255, 255, 255, .09);
}

.contact-card span {
  display: block;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, .68);
}

.contact-card a {
  color: var(--white);
}

.contact-hero,
.factory-section {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.contact-hero {
  padding: 72px 0 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 36px;
  align-items: end;
}

.contact-info-panel {
  padding: 24px;
  display: grid;
  gap: 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow);
}

.contact-info-panel div {
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}

.contact-info-panel div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.contact-info-panel span {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, .64);
  font-size: 13px;
  font-weight: 800;
}

.contact-info-panel strong {
  overflow-wrap: anywhere;
  font-size: 22px;
}

.factory-section {
  padding-bottom: 46px;
}

.factory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

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

.factory-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 12px 30px rgba(29, 37, 44, .07);
}

.factory-card h3 {
  margin: 16px 16px 8px;
  font-size: 18px;
}

.factory-card p {
  margin: 0 16px 18px;
  color: var(--muted);
  line-height: 1.65;
}

.factory-placeholder {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--green-dark);
  background:
    linear-gradient(135deg, rgba(17, 116, 111, .12), rgba(239, 179, 76, .16)),
    #eef1f5;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
}

.factory-placeholder strong {
  display: block;
  font-size: 24px;
}

.back-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: var(--white);
  box-shadow: var(--shadow);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

.detail-dialog {
  width: min(1120px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.detail-dialog::backdrop {
  background: rgba(15, 23, 32, .62);
}

.dialog-shell {
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 28px);
  background: var(--white);
  border-radius: 8px;
}

.close-button {
  position: sticky;
  top: 12px;
  left: calc(100% - 54px);
  z-index: 3;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.detail-layout {
  padding: 22px 26px 30px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 26px;
}

.detail-gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.detail-preview-btn {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.detail-preview {
  width: 100%;
  min-height: 260px;
  max-height: 520px;
  object-fit: contain;
  object-position: center center;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f5f8;
}

.detail-preview-empty {
  min-height: 260px;
}

.detail-thumbs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-thumb {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f5f8;
  overflow: hidden;
  cursor: zoom-in;
}

.detail-thumb.active {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(17, 116, 111, .12);
}

.detail-thumb img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center center;
  display: block;
}

.detail-gallery .no-image {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-info {
  position: sticky;
  top: 20px;
  align-self: start;
}

.detail-code {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.detail-code strong {
  color: var(--ink);
  margin-right: 8px;
}

.detail-fields {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px 14px;
  margin: 22px 0;
}

.detail-fields dt {
  color: var(--muted);
  font-weight: 800;
}

.detail-fields dt strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.detail-fields dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-contact {
  width: 100%;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

.admin-toolbar input {
  width: 220px;
}

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

.admin-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 12px 30px rgba(29, 37, 44, .06);
}

.admin-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.admin-list {
  display: grid;
  gap: 8px;
  max-height: 760px;
  overflow: auto;
  padding-right: 4px;
}

.admin-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}

.admin-item.active {
  border-color: var(--green);
  background: rgba(17, 116, 111, .08);
}

.admin-item strong,
.admin-item small {
  display: block;
}

.admin-form {
  display: grid;
  gap: 14px;
}

.admin-form label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.admin-form input,
.admin-form textarea,
.admin-form select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  font: inherit;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  .hero,
  .contact-hero,
  .contact,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding-top: 12px;
    padding-bottom: 12px;
    grid-template-columns: 1fr;
  }

  .top-search {
    max-width: none;
    margin: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .top-search-copy {
    min-width: 0;
  }

  .hero {
    padding-top: 44px;
  }

  .stats {
    max-width: 420px;
  }

  .catalog-layout {
    grid-template-columns: 1fr;
    padding-bottom: 28px;
  }

  .category-section {
    position: static;
  }

  .type-grid {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .section-title {
    display: block;
  }

  .grid,
  .factory-grid,
  .factory-grid.wide,
  .detail-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .detail-info {
    position: static;
  }

  .admin-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .admin-toolbar {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

@media (max-width: 500px) {
  .top-contact {
    display: none;
  }

  .stats,
  .factory-grid,
  .factory-grid.wide,
  .detail-gallery {
    grid-template-columns: 1fr;
  }

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

  .type-card {
    width: calc(50% - 4px);
  }

  .detail-layout {
    padding: 18px 16px 24px;
  }
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

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

  .product-card img {
    width: 100%;
    height: 100%;
  }

  .image-wrap {
    height: 180px;
  }

  .no-image {
    min-height: 0;
  }

  .product-info {
    padding: 5px;
    gap: 4px;
  }

  .product-name {
    margin-bottom: 0;
    min-height: 2.3em;
    font-size: 9px;
    line-height: 1.15;
  }

  .product-code {
    margin-bottom: 0;
    min-height: 2.1em;
    font-size: 8px;
  }

  .product-code strong,
  .product-code small {
    font-size: 8px;
  }

  .tag {
    min-height: 18px;
    padding: 1px 4px;
    font-size: 8px;
  }

  .tag strong,
  .tag small {
    font-size: 8px;
  }

  .image-count {
    right: 6px;
    bottom: 6px;
    min-height: 18px;
    padding: 0 6px;
    font-size: 8px;
  }

  .detail-thumbs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .detail-preview {
    min-height: 180px;
  }
}
