:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --ink: #202623;
  --muted: #63706a;
  --line: #d9e0dc;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #147d47;
  --shadow: 0 14px 34px rgba(30, 44, 37, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 48px);
  background: rgba(244, 246, 244, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #12312c;
  color: #e9fff9;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-logo {
  display: block;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border: 1px solid rgba(18, 49, 44, 0.16);
  border-radius: 10px;
  background: #050505;
  object-fit: cover;
  object-position: center 42%;
  box-shadow: 0 8px 20px rgba(18, 49, 44, 0.12);
}

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

h1 {
  font-size: clamp(20px, 2.5vw, 28px);
  line-height: 1.1;
}

.brand p,
.panel-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.icon-button[data-tooltip]::before,
.icon-button[data-tooltip]::after {
  position: absolute;
  left: 50%;
  z-index: 30;
  opacity: 0;
  transform: translate(-50%, -4px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.icon-button[data-tooltip]::before {
  top: calc(100% + 4px);
  width: 8px;
  height: 8px;
  background: #12312c;
  content: "";
  rotate: 45deg;
}

.icon-button[data-tooltip]::after {
  top: calc(100% + 8px);
  width: max-content;
  max-width: 220px;
  padding: 7px 9px;
  border-radius: 8px;
  background: #12312c;
  color: #fff;
  content: attr(data-tooltip);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(18, 49, 44, 0.18);
}

.icon-button[data-tooltip]:hover::before,
.icon-button[data-tooltip]:hover::after,
.icon-button[data-tooltip]:focus-visible::before,
.icon-button[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.site-footer {
  padding: 0 clamp(16px, 4vw, 48px) 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px) 44px;
}

.builder-panel,
.summary-panel {
  min-width: 0;
}

.builder-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  min-width: 0;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
}

.budget-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.price-range-control label {
  text-align: center;
}

.price-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.price-range-control .money-input {
  width: 128px;
}

.range-separator {
  color: var(--muted);
  font-size: 13px;
}

.money-input {
  display: flex;
  align-items: center;
  width: 164px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.money-input input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

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

.category-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(30, 44, 37, 0.05);
}

.category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.category-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--accent-strong);
}

.category-icon svg {
  width: 18px;
  height: 18px;
}

.category-title h3 {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-thumb {
  display: grid;
  width: 54px;
  height: 40px;
  padding: 0;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 52%),
    #fff;
  cursor: zoom-in;
}

.category-thumb:hover {
  border-color: var(--accent);
}

.category-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.required,
.optional {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e4f5ef;
  color: var(--ok);
  font-size: 12px;
  font-weight: 700;
}

.optional {
  background: var(--surface-2);
  color: var(--muted);
}

.part-select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.part-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.meta-pill {
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.meta-pill strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
}

.product-detail {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.product-detail.empty {
  color: var(--muted);
  font-size: 13px;
}

.product-image {
  display: grid;
  width: 100%;
  height: 132px;
  padding: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 48%),
    #fff;
  cursor: zoom-in;
}

.product-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

body.modal-open {
  overflow: hidden;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 24px;
}

.image-lightbox.show {
  display: grid;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(11, 20, 17, 0.72);
  cursor: zoom-out;
}

.lightbox-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  width: min(1280px, calc(100vw - 40px));
  max-height: calc(100vh - 48px);
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.lightbox-panel img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  background: #fff;
}

.lightbox-panel figcaption {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
}

.lightbox-close svg {
  width: 18px;
  height: 18px;
}

.product-main {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.product-main > div {
  min-width: 0;
}

.product-brand {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.product-main strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.3;
}

.product-main a {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  text-decoration: none;
}

.product-main a:hover {
  border-color: var(--accent);
  background: #e4f5ef;
}

.product-main svg {
  width: 16px;
  height: 16px;
}

.product-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.product-stats span {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 8px;
  background: var(--surface-2);
}

.product-stats strong {
  color: var(--ink);
}

.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.product-tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e4f5ef;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

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

.summary-panel {
  position: sticky;
  top: 180px;
  align-self: start;
  display: grid;
  gap: 18px;
  margin-top: 82px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-badge.ok {
  background: #e4f5ef;
  color: var(--ok);
}

.status-badge.warn {
  background: #fff3df;
  color: var(--warn);
}

.status-badge.danger {
  background: #fff0ed;
  color: var(--danger);
}

.customer-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.customer-field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.customer-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.usage-field {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}

.usage-field legend {
  padding: 0 5px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.usage-options {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 8px 4px;
  align-items: center;
}

.usage-options label,
.usage-other-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.usage-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.usage-other-choice {
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.usage-other-input {
  flex: 1;
  min-width: 0;
  max-width: 170px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.usage-other-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

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

.metric {
  min-width: 0;
  padding: 13px;
  border-radius: 8px;
  background: var(--surface-2);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 20px;
  line-height: 1.2;
}

.progress-block,
.score-block,
.compatibility-block,
.selected-block {
  display: grid;
  gap: 10px;
}

.score-block {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 55%),
    var(--surface);
}

.score-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score-head h3 {
  font-size: 15px;
}

.score-head strong {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 999px;
  background: #12312c;
  color: #e9fff9;
  font-size: 20px;
  line-height: 1;
}

.score-list {
  display: grid;
  gap: 8px;
}

.score-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.score-row strong {
  color: var(--ink);
  text-align: right;
}

.score-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.score-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #f97316);
  transition: width 180ms ease;
}

.score-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease, background 180ms ease;
}

.progress-bar.over {
  background: var(--danger);
}

.compatibility-block h3,
.selected-block h3 {
  font-size: 15px;
}

.message-list,
.selected-list {
  display: grid;
  gap: 8px;
}

.message {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.message svg {
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

.message.ok {
  color: var(--ok);
}

.message.warn {
  color: var(--warn);
  background: #fff7e8;
}

.message.danger {
  color: var(--danger);
  background: #fff0ed;
}

.selected-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.selected-item:last-child {
  border-bottom: 0;
}

.selected-item span {
  color: var(--muted);
}

.selected-item strong {
  max-width: 220px;
  overflow-wrap: anywhere;
  text-align: right;
}

.selected-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

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

.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.order-button {
  grid-column: 1 / -1;
}

.export-button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.export-button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.export-button.secondary:hover {
  border-color: var(--accent);
  background: #e4f5ef;
  color: var(--accent-strong);
}

.reset-config-button {
  min-height: 34px;
  padding-inline: 11px;
  white-space: nowrap;
}

.export-button:disabled {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: wait;
}

.export-button svg {
  width: 17px;
  height: 17px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(340px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #12312c;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
    margin-top: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-title-row {
    justify-content: space-between;
  }

  .budget-control,
  .money-input {
    width: 100%;
  }

  .price-range-inputs {
    align-items: stretch;
    flex-direction: column;
  }

  .price-range-control .money-input {
    width: 100%;
  }

  .range-separator {
    align-self: center;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .topbar {
    padding-inline: 12px;
  }

  .app-shell {
    padding-inline: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
  }

  .metric-grid,
  .export-actions,
  .part-meta,
  .product-stats {
    grid-template-columns: 1fr;
  }
}
