:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --line-strong: #b7c2d0;
  --blue: #1f5eff;
  --blue-dark: #1749c6;
  --green: #12805c;
  --red: #c9362b;
  --shadow: 0 18px 40px rgba(20, 32, 55, 0.12);
  --sidebar: 320px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fff;
  z-index: 20;
}

.brand-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-row img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #111;
}

.brand-row strong,
.brand-row span {
  display: block;
}

.brand-row strong {
  font-size: 18px;
}

.brand-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.side-tools {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.side-tools input,
.admin-form input,
.admin-form textarea,
.admin-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
  outline: none;
}

.side-tools input:focus,
.admin-form input:focus,
.admin-form textarea:focus,
.admin-form select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.12);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px;
  background: var(--surface-2);
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
}

.segmented .active {
  color: #fff;
  background: var(--blue);
}

.tree {
  display: grid;
  gap: 12px;
  padding: 16px 14px 32px;
}

.tree-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.tree-title {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border: 0;
  padding: 0 12px;
  background: var(--surface-2);
  text-align: left;
}

.chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}

.tree-group.collapsed .chevron {
  transform: rotate(-45deg);
}

.tree-title em,
.panel-title span,
.status {
  border-radius: 999px;
  padding: 4px 8px;
  color: #475467;
  background: #e9eef6;
  font-size: 12px;
  font-style: normal;
}

.tree-list {
  display: grid;
  gap: 3px;
  padding: 8px;
}

.tree-group.collapsed .tree-list {
  display: none;
}

.tree-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 38px;
  border-radius: 6px;
  padding: 7px 9px;
  text-decoration: none;
}

.tree-item:hover,
.tree-item.active {
  background: #ecf2ff;
}

.tree-item.active {
  box-shadow: inset 3px 0 0 var(--blue);
}

.tree-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.tree-item small {
  color: var(--muted);
}

.main {
  min-width: 0;
  padding: 22px clamp(14px, 2.6vw, 36px) 64px;
}

.scrim {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar p {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.topbar h1,
.detail h2,
.panel h3 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

.admin-link,
.btn,
.download-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.language-form select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
}

.btn.primary,
.admin-form .primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpis div,
.panel,
.detail-head,
.image-console,
.part-inspector,
.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.kpis div {
  padding: 14px;
}

.kpis span {
  display: block;
  color: var(--blue);
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
}

.kpis strong {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.product-card {
  min-width: 0;
  overflow: hidden;
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.product-card:hover,
.product-card.active {
  transform: translateY(-2px);
  border-color: var(--blue);
  box-shadow: var(--shadow);
}

.product-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f3f6fa;
}

.product-card div {
  display: grid;
  gap: 7px;
  padding: 12px;
}

.product-card span {
  color: var(--muted);
  font-size: 12px;
}

.product-card strong {
  min-height: 42px;
  font-size: 14px;
  line-height: 1.45;
}

.detail {
  display: grid;
  gap: 16px;
  scroll-margin-top: 18px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
}

.detail-head h2 {
  margin-top: 10px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.15;
}

.detail-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 16px;
  align-items: stretch;
}

.image-console {
  overflow: hidden;
}

.main-image-wrap {
  position: relative;
  background: #f5f7fb;
}

.main-image-wrap > img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
}

.zoom-hotspot {
  position: absolute;
  right: 14px;
  bottom: 14px;
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  color: #fff;
  background: rgba(23, 32, 51, 0.86);
}

.part-hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.part-dot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.28);
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.part-dot.active {
  background: var(--red);
}

.part-dot::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0.35;
}

.thumb-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.thumb {
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  background: #f3f6fa;
}

.thumb.active {
  border-color: var(--blue);
}

.thumb img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.part-inspector {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
}

.part-detail {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  text-align: left;
}

.part-detail.active,
.part-detail:hover {
  border-color: var(--blue);
  background: #ecf2ff;
}

.part-detail img {
  width: 86px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  background: #f3f6fa;
}

.part-detail span {
  font-weight: 700;
  line-height: 1.4;
}

.info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.specs-panel table {
  width: 100%;
  border-collapse: collapse;
}

.specs-panel th,
.specs-panel td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
}

.specs-panel th {
  width: 160px;
  color: var(--muted);
}

.copy-block + .copy-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.copy-block h4 {
  margin: 0 0 8px;
}

.copy-block p {
  margin: 0;
  color: #344054;
  line-height: 1.8;
}

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

.part-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: var(--surface-2);
  text-align: left;
}

.part-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.part-card span {
  display: block;
  min-height: 42px;
  padding: 8px;
  font-size: 13px;
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-bottom-actions {
  display: flex;
  justify-content: center;
}

.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(10, 18, 32, 0.82);
  z-index: 60;
}

.lightbox.open {
  display: grid;
}

.lightbox img {
  max-width: min(1200px, 94vw);
  max-height: 88vh;
  object-fit: contain;
  background: #fff;
}

.lightbox button {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  font-size: 28px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.mobile-only {
  display: none;
}

.hidden {
  display: none !important;
}

.admin-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-list,
.admin-form,
.login-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-list {
  padding: 12px;
}

.admin-list a {
  display: block;
  border-radius: 6px;
  padding: 10px;
  text-decoration: none;
}

.admin-list a.active,
.admin-list a:hover {
  background: #ecf2ff;
}

.admin-form {
  padding: 18px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.admin-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.admin-form textarea {
  min-height: 120px;
  resize: vertical;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.form-actions button,
.form-actions a,
.login-box button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  text-decoration: none;
}

.danger {
  color: var(--red);
}

.notice {
  border: 1px solid #b7ebd8;
  border-radius: 6px;
  margin-bottom: 14px;
  padding: 10px 12px;
  color: #05603a;
  background: #ecfdf3;
}

.login-box {
  max-width: 420px;
  margin: 12vh auto;
  padding: 22px;
}

.login-box label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

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

.settings-grid .wide {
  grid-column: 1 / -1;
}

.translation-panel,
.settings-panel {
  margin-top: 16px;
}

.hotspot-panel {
  margin-top: 16px;
}

.hotspot-editor {
  display: grid;
  gap: 12px;
}

.hotspot-editor-canvas {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7fb;
  touch-action: none;
}

.hotspot-editor-canvas img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  user-select: none;
}

.hotspot-editor-dot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.3);
  transform: translate(-50%, -50%);
  touch-action: none;
}

.hotspot-editor-dot.dragging {
  background: var(--red);
  transform: translate(-50%, -50%) scale(1.08);
}

.hotspot-editor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hotspot-editor-list span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: #344054;
  background: var(--surface-2);
  font-size: 12px;
}

.hotspot-editor-list b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
}

.settings-subtitle {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}

.settings-subtitle:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.muted-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1180px) {
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 920px) {
  .layout {
    display: block;
  }

  .mobile-only {
    display: inline-grid;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 350px);
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    box-shadow: var(--shadow);
  }

  body.tree-open .sidebar {
    transform: translateX(0);
  }

  .brand-row {
    grid-template-columns: 48px minmax(0, 1fr) 42px;
  }

  .brand-row img {
    width: 48px;
    height: 48px;
  }

  .scrim {
    position: fixed;
    inset: 0;
    display: none;
    background: rgba(23, 32, 51, 0.42);
    z-index: 15;
  }

  body.tree-open .scrim {
    display: block;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 12;
    margin: -22px -14px 16px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: rgba(238, 241, 245, 0.94);
    backdrop-filter: blur(12px);
  }

  .topbar p {
    display: none;
  }

  .topbar h1 {
    font-size: 22px;
  }

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

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

  .detail-head,
  .detail-grid,
  .info-grid,
  .admin-grid,
  .form-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .detail-head {
    display: grid;
  }

  .detail-actions {
    justify-content: flex-start;
  }

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

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

  .kpis,
  .cards,
  .parts-grid,
  .thumb-row {
    grid-template-columns: 1fr;
  }

  .product-card {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
  }

  .product-card img {
    height: 100%;
    aspect-ratio: auto;
  }

  .product-card strong {
    min-height: 0;
  }

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

  .specs-panel table,
  .specs-panel tbody,
  .specs-panel tr,
  .specs-panel th,
  .specs-panel td {
    display: block;
    width: 100%;
  }

  .specs-panel tr {
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
  }

  .specs-panel th,
  .specs-panel td {
    border: 0;
    padding: 4px 0;
  }
}
