:root {
  --bg: #f4f6f8;
  --paper: #ffffff;
  --ink: #171717;
  --muted: #667085;
  --line: #d8dee6;
  --soft: #eef3f7;
  --brand: #111827;
  --gold: #b9862f;
  --accent: #2563eb;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

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

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  border-color: #aab3c1;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.ghost {
  padding: 6px 10px;
  color: var(--muted);
}

.app {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  min-height: 100vh;
}

.panel {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 18px;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #3f3321);
  color: #f5d08d;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.card,
.selected-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 16px;
}

.section-title span,
.toolbar span {
  color: var(--muted);
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: #344054;
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.compact-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.compact-actions button {
  padding: 8px 6px;
  font-size: 12px;
}

.file-import input {
  padding: 8px;
}

.preset-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.preset {
  text-align: left;
  background: #f8fafc;
}

.family-options {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.option-row {
  margin-bottom: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
}

.check-row span {
  font-size: 13px;
}

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

.area-preset {
  display: grid;
  gap: 4px;
  text-align: left;
  background: linear-gradient(180deg, #ffffff, #f7f9fc);
  border-color: #cfd7e3;
  min-height: 92px;
}

.area-preset:hover {
  border-color: #8aa6e8;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.12);
}

.area-preset strong {
  color: #111827;
  font-size: 20px;
  line-height: 1;
}

.area-preset span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.area-preset small {
  color: #475467;
  font-size: 11px;
  line-height: 1.2;
}

.area-preset em {
  color: var(--danger);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.search {
  margin-bottom: 10px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filter {
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  color: #344054;
}

.filter.active {
  background: #e8eefc;
  border-color: #9fb5f1;
  color: #1d4ed8;
}

.product-list {
  display: grid;
  gap: 8px;
  max-height: 48vh;
  overflow-y: auto;
}

.product {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.product img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: #f8fafc;
  border-radius: 6px;
}

.image-empty {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #f8fafc;
  border-radius: 6px;
  font-size: 12px;
}

.product strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.product p {
  margin: 4px 0 7px;
  font-size: 12px;
  color: var(--muted);
}

.product footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.price-rule {
  margin-top: 6px;
  color: #7a4b00;
  background: #fff7e6;
  border: 1px solid #f3d39a;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  line-height: 1.35;
}

.price {
  color: var(--danger);
  font-weight: 800;
}

.add-btn {
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 12px;
}

.workspace {
  padding: 18px;
  overflow-x: hidden;
}

.toolbar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  position: sticky;
  top: 0;
  z-index: 5;
}

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

.selected-items {
  display: grid;
  gap: 10px;
}

.room-card {
  border: 1px solid #c8d7eb;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #f8fbff, #eef6ff);
}

.room-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: end;
  margin-bottom: 12px;
}

.room-head strong {
  display: block;
  font-size: 16px;
}

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

.room-active label {
  margin-bottom: 0;
}

.room-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 120px 120px;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.room-form label {
  margin-bottom: 0;
}

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

.room-pill {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 5px;
  border: 1px solid #d6e0ee;
  border-radius: 8px;
  background: #fff;
}

.room-pill.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.room-pill button {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 7px 9px;
  background: transparent;
  border: 0;
}

.room-pill strong {
  font-size: 13px;
}

.room-pill span {
  color: var(--muted);
  font-size: 11px;
}

.room-pill input {
  width: 68px;
  padding: 7px;
}

.room-remove {
  width: 32px;
  padding: 0;
  color: var(--danger);
}

.custom-line-card {
  border: 1px dashed #9fb2c8;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #f8fbff, #eef7ff);
}

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

.custom-line-head strong {
  display: block;
  font-size: 16px;
}

.custom-line-head span {
  color: var(--muted);
  font-size: 12px;
}

.custom-line-form {
  display: grid;
  grid-template-columns: minmax(160px, 1.3fr) 88px 92px 120px minmax(180px, 1fr);
  gap: 10px;
  align-items: end;
}

.custom-line-form label,
.inline-edit {
  display: grid;
  gap: 5px;
}

.custom-line-form input,
.inline-edit input {
  width: 100%;
}

.selected-items.empty {
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.selected-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 150px 88px 118px 118px 34px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.custom-selected-row {
  grid-template-columns: minmax(0, 1.3fr) 150px 82px 88px 118px 118px 34px;
  background: #f7fbff;
  border-style: dashed;
}

.selected-row strong {
  display: block;
  font-size: 14px;
}

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

.selected-row input {
  padding: 8px;
}

.remove {
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--danger);
}

.preview-wrap {
  overflow: auto;
  padding-bottom: 40px;
}

.quote-page {
  width: 1080px;
  min-height: 1200px;
  margin: 0 auto;
  background: #fff;
  color: #111;
  border: 1px solid #d0d5dd;
  padding: 28px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
}

.quote-head {
  border: 3px solid #111;
  margin-bottom: 12px;
}

.quote-title {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  background: #f5f6f8;
  border-bottom: 2px solid #111;
}

.quote-logo {
  width: 90px;
  height: 90px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #111827, #6b4e20);
  color: #f4d18d;
  font-weight: 900;
  text-align: center;
}

.logo-mark {
  font-size: 38px;
  line-height: 1;
}

.quote-logo small {
  color: #fff3cf;
  font-size: 12px;
}

.quote-title h2 {
  margin: 0;
  text-align: center;
  font-size: 32px;
  letter-spacing: 0;
}

.quote-subtitle {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  padding: 12px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  border: 2px solid #111;
  border-bottom: 0;
  padding: 12px 14px;
  font-size: 15px;
}

.info-grid div:last-child {
  grid-column: 1 / -1;
}

.quote-summary-table,
.quote-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.quote-table .col-serial { width: 52px; }
.quote-table .col-name { width: 112px; }
.quote-table .col-model { width: 88px; }
.quote-table .col-product-image { width: 120px; }
.quote-table .col-effect-image { width: 120px; }
.quote-table .col-spec { width: 170px; }
.quote-table .col-unit { width: 62px; }
.quote-table .col-qty { width: 72px; }
.quote-table .col-price { width: 86px; }
.quote-table .col-amount { width: 98px; }

.quote-summary-table th,
.quote-summary-table td,
.quote-table th,
.quote-table td {
  border: 2px solid #111;
  padding: 8px 7px;
  vertical-align: middle;
  word-break: break-word;
  overflow: hidden;
}

.quote-summary-table .center,
.quote-table .center {
  text-align: center;
}

.quote-summary-table .right,
.quote-table .right {
  text-align: right;
}

.quote-summary-table th,
.quote-table th {
  background: #e8b9bb;
  font-size: 15px;
}

.quote-summary-table {
  margin-bottom: 14px;
  font-size: 16px;
}

.quote-summary-table td {
  height: 46px;
}

.quote-detail-section {
  margin-top: 16px;
  break-inside: avoid;
}

.detail-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 2px solid var(--quote-line);
  border-bottom: 0;
  background: var(--quote-head);
  padding: 12px 14px;
}

.detail-title h3 {
  margin: 0;
  text-align: center;
  font-size: 24px;
  letter-spacing: 0;
}

.detail-title span {
  color: var(--quote-muted);
  font-size: 13px;
  font-weight: 700;
}

.image-cell {
  padding: 6px;
}

.quote-image-box {
  width: 104px;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0 auto;
}

.quote-table .quote-image-box img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
}

.spec {
  font-size: 12px;
  line-height: 1.3;
  max-height: 132px;
  white-space: pre-line;
  overflow: hidden;
}

.empty-preview {
  text-align: center;
  padding: 32px;
  color: var(--muted);
}

.summary-row td {
  background: #e8e8e8;
  font-weight: 900;
  font-size: 18px;
}

.note {
  border: 2px solid #111;
  border-top: 0;
  text-align: center;
  color: #c00000;
  font-weight: 900;
  padding: 12px;
  background: #fffdf4;
}

.quote-page {
  --quote-bg: #ffffff;
  --quote-ink: #111111;
  --quote-muted: #4b5563;
  --quote-line: #111111;
  --quote-head: #f5f6f8;
  --quote-th: #e8b9bb;
  --quote-summary: #e8e8e8;
  --quote-note-bg: #fffdf4;
  --quote-note: #c00000;
  --quote-logo-a: #111827;
  --quote-logo-b: #6b4e20;
  background: var(--quote-bg);
  color: var(--quote-ink);
}

.quote-page .quote-head,
.quote-page .info-grid,
.quote-page .quote-summary-table th,
.quote-page .quote-summary-table td,
.quote-page .quote-table th,
.quote-page .quote-table td,
.quote-page .note {
  border-color: var(--quote-line);
}

.quote-page .quote-title {
  background: var(--quote-head);
  border-color: var(--quote-line);
}

.quote-page .quote-logo {
  background: linear-gradient(135deg, var(--quote-logo-a), var(--quote-logo-b));
}

.quote-page .quote-summary-table th,
.quote-page .quote-table th {
  background: var(--quote-th);
  color: var(--quote-ink);
}

.quote-page .summary-row td {
  background: var(--quote-summary);
  color: var(--quote-ink);
}

.quote-page .note {
  background: var(--quote-note-bg);
  color: var(--quote-note);
}

.template-white-future {
  --quote-bg: linear-gradient(135deg, #ffffff 0%, #eef8ff 100%);
  --quote-ink: #0f172a;
  --quote-line: #153e75;
  --quote-head: linear-gradient(135deg, #e0f2fe, #f8fbff);
  --quote-th: #bfdbfe;
  --quote-summary: #dbeafe;
  --quote-logo-a: #075985;
  --quote-logo-b: #22d3ee;
}

.template-white-circuit {
  --quote-bg: linear-gradient(135deg, #ffffff 0%, #f4f7fb 100%);
  --quote-ink: #111827;
  --quote-line: #334155;
  --quote-head: linear-gradient(135deg, #f8fafc, #e2e8f0);
  --quote-th: #cbd5e1;
  --quote-summary: #e2e8f0;
  --quote-logo-a: #111827;
  --quote-logo-b: #64748b;
}

.template-white-aurora {
  --quote-bg: linear-gradient(135deg, #ffffff 0%, #effdf7 100%);
  --quote-ink: #052e2b;
  --quote-line: #0f766e;
  --quote-head: linear-gradient(135deg, #ccfbf1, #f6fffb);
  --quote-th: #99f6e4;
  --quote-summary: #ccfbf1;
  --quote-logo-a: #064e3b;
  --quote-logo-b: #2dd4bf;
}

.template-white-gold {
  --quote-bg: linear-gradient(135deg, #ffffff 0%, #fff8e7 100%);
  --quote-ink: #23180a;
  --quote-line: #92400e;
  --quote-head: linear-gradient(135deg, #fef3c7, #fffdf5);
  --quote-th: #fde68a;
  --quote-summary: #fef3c7;
  --quote-logo-a: #1c1917;
  --quote-logo-b: #b45309;
}

.template-white-laser {
  --quote-bg: linear-gradient(135deg, #ffffff 0%, #f7f1ff 100%);
  --quote-ink: #25133f;
  --quote-line: #6d28d9;
  --quote-head: linear-gradient(135deg, #ede9fe, #ffffff);
  --quote-th: #ddd6fe;
  --quote-summary: #ede9fe;
  --quote-logo-a: #312e81;
  --quote-logo-b: #d946ef;
}

.template-dark-neon,
.template-dark-matrix,
.template-dark-laser,
.template-dark-gold,
.template-dark-red {
  --quote-ink: #f8fdff;
  --quote-muted: #b6c6d4;
  color: var(--quote-ink);
}

.template-dark-neon {
  --quote-bg: linear-gradient(135deg, #06111f 0%, #020713 100%);
  --quote-line: #38bdf8;
  --quote-head: linear-gradient(135deg, #082f49, #0b1220);
  --quote-th: #075985;
  --quote-summary: #0c4a6e;
  --quote-note-bg: #082f49;
  --quote-note: #67e8f9;
  --quote-logo-a: #0f172a;
  --quote-logo-b: #06b6d4;
}

.template-dark-matrix {
  --quote-bg: linear-gradient(135deg, #03170f 0%, #020806 100%);
  --quote-line: #22c55e;
  --quote-head: linear-gradient(135deg, #064e3b, #06130e);
  --quote-th: #166534;
  --quote-summary: #14532d;
  --quote-note-bg: #052e16;
  --quote-note: #86efac;
  --quote-logo-a: #022c22;
  --quote-logo-b: #22c55e;
}

.template-dark-laser {
  --quote-bg: linear-gradient(135deg, #110720 0%, #05020a 100%);
  --quote-line: #c084fc;
  --quote-head: linear-gradient(135deg, #3b0764, #12051f);
  --quote-th: #6b21a8;
  --quote-summary: #581c87;
  --quote-note-bg: #2e1065;
  --quote-note: #f0abfc;
  --quote-logo-a: #1e1b4b;
  --quote-logo-b: #c026d3;
}

.template-dark-gold {
  --quote-bg: linear-gradient(135deg, #16110a 0%, #050403 100%);
  --quote-line: #f59e0b;
  --quote-head: linear-gradient(135deg, #451a03, #171009);
  --quote-th: #92400e;
  --quote-summary: #78350f;
  --quote-note-bg: #1c1307;
  --quote-note: #fcd34d;
  --quote-logo-a: #0c0a09;
  --quote-logo-b: #d97706;
}

.template-dark-red {
  --quote-bg: linear-gradient(135deg, #17070b 0%, #031020 100%);
  --quote-line: #fb7185;
  --quote-head: linear-gradient(135deg, #881337, #082f49);
  --quote-th: #9f1239;
  --quote-summary: #7f1d1d;
  --quote-note-bg: #111827;
  --quote-note: #fda4af;
  --quote-logo-a: #111827;
  --quote-logo-b: #e11d48;
}

@media (max-width: 900px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  .app {
    display: block;
    width: 100%;
    overflow-x: hidden;
  }

  .panel {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    width: 100%;
    padding: 14px;
    overflow-x: hidden;
  }

  .card,
  .selected-card {
    width: 100%;
    padding: 12px;
  }

  .section-title {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: flex-start;
  }

  .section-title span {
    max-width: 132px;
    text-align: left;
  }

  .section-title button {
    justify-self: start;
    padding: 7px 10px;
    white-space: nowrap;
  }

  .compact-actions {
    grid-template-columns: 1fr 1fr;
  }

  .compact-actions button {
    min-width: 0;
    white-space: nowrap;
  }

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

  .area-preset {
    min-height: 86px;
    padding: 10px;
  }

  .workspace {
    padding: 12px;
    overflow-x: hidden;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }

  .custom-line-head {
    display: grid;
    gap: 10px;
  }

  .room-head,
  .room-form {
    grid-template-columns: 1fr;
  }

  .room-pill {
    width: 100%;
  }

  .room-pill button {
    flex: 1;
  }

  .custom-line-form {
    grid-template-columns: 1fr 1fr;
  }

  .custom-note-field {
    grid-column: 1 / -1;
  }

  .selected-row {
    grid-template-columns: 1fr 1fr;
  }

  .custom-selected-row {
    grid-template-columns: 1fr 1fr;
  }

  .selected-row .line-total {
    grid-column: 1 / -1;
  }

  .preview-wrap {
    width: 100%;
    overflow: hidden;
  }

  .product-list {
    max-height: 72vh;
  }

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

  .product img,
  .image-empty {
    width: 46px;
    height: 46px;
  }

  .price-rule {
    font-size: 10px;
  }

  .quote-page {
    width: 1080px;
    transform: scale(0.34);
    transform-origin: top left;
    margin-right: -700px;
    margin-bottom: -610px;
  }
}
