:root {
  --bg: #f5f1e8;
  --panel: rgba(255, 255, 255, 0.92);
  --ink: #17231f;
  --muted: #6b7a75;
  --teal: #0f766e;
  --teal-dark: #0b5f58;
  --gold: #f8d463;
  --gold-soft: #fff1d9;
  --line: #1f2933;
  --green: #10b981;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  max-width: 1180px;
  min-height: 100vh;
  margin: 0 auto;
  background: rgba(245, 241, 232, 0.96);
}

.hero {
  position: relative;
  min-height: 310px;
  overflow: hidden;
}

.hero-bg,
.hero-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-bg {
  object-fit: cover;
}

.hero-shade {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.24));
}

.hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  min-height: 310px;
  padding: 42px 34px 28px;
  color: #fff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.15;
  font-weight: 900;
}

.hero p {
  margin-top: 10px;
  font-size: 17px;
  color: rgba(255, 255, 255, 0.86);
}

.quote-actions {
  display: grid;
  gap: 12px;
  width: 230px;
}

.primary-action,
.summary-btn,
.export-btn,
.add-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--gold);
  color: #24352f;
  font-weight: 800;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.primary-action.secondary,
.summary-btn,
.export-btn {
  background: var(--teal);
  color: #fff;
}

main {
  padding: 20px 18px 34px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-head,
.sticky-bar,
.summary-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 21px;
  line-height: 1.2;
}

.section-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.search-input,
select {
  height: 42px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.search-input {
  width: min(420px, 100%);
  padding: 0 14px;
}

select {
  min-width: 190px;
  padding: 0 12px;
}

.card,
.category-panel,
.product-card,
.quote-card {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(22, 31, 28, 0.08);
}

.category-list,
.quote-list {
  display: grid;
  gap: 12px;
}

.quote-category-tabs {
  position: sticky;
  top: 64px;
  z-index: 4;
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px 0;
  overflow-x: auto;
  background: var(--bg);
}

.quote-category-tab {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  background: #fff;
  color: var(--teal);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 1px 8px rgba(22, 31, 28, 0.06);
}

.quote-category-panel {
  overflow: hidden;
  border-radius: 8px;
}

.category-header,
.quote-category-header {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: rgba(255, 255, 255, 0.94);
}

.quote-category-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 50px;
  padding: 0 16px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 900;
}

.quote-category-toggle span {
  color: #8b7b48;
  font-size: 13px;
}

.quote-category-body {
  display: none;
  gap: 12px;
  padding-top: 10px;
}

.quote-category-panel.is-open .quote-category-body {
  display: grid;
}

.category-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  padding: 0 16px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
}

.category-order-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  padding-right: 10px;
}

.category-drag-handle {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--teal);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.category-drag-handle:active,
.is-category-dragging .category-drag-handle {
  cursor: grabbing;
}

.category-panel.is-dragging,
.quote-category-panel.is-dragging {
  opacity: 0.55;
}

.category-panel.is-drag-over,
.quote-category-panel.is-drag-over {
  box-shadow: inset 0 3px 0 var(--teal), 0 8px 24px rgba(22, 31, 28, 0.08);
}

.category-panel.is-drag-after,
.quote-category-panel.is-drag-after {
  box-shadow: inset 0 -3px 0 var(--teal), 0 8px 24px rgba(22, 31, 28, 0.08);
}

.category-toggle span:last-child {
  color: #8b7b48;
  font-size: 13px;
}

.category-body {
  display: none;
  gap: 10px;
  padding: 0 12px 12px;
}

.category-panel.is-open .category-body {
  display: grid;
}

.product-card {
  padding: 14px;
}

.product-head,
.quote-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.model {
  color: #168985;
  font-weight: 900;
}

.category-tag {
  color: #8b7b48;
  font-size: 13px;
}

.product-name,
.quote-name {
  margin-top: 8px;
  font-size: 17px;
  font-weight: 900;
}

.spec-table,
.quote-table {
  display: grid;
  margin-top: 12px;
  border-radius: 6px;
  overflow: hidden;
}

.spec-row,
.spec-head {
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.8fr 0.8fr;
  min-width: 0;
}

.spec-head {
  background: #e5f2ef;
  color: #54726d;
  font-size: 13px;
  font-weight: 800;
}

.spec-row {
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  color: #43554f;
  font-size: 13px;
}

.spec-row span,
.spec-head span {
  min-width: 0;
  padding: 7px 9px;
  overflow-wrap: anywhere;
}

.spec-row span:nth-child(3),
.spec-row span:nth-child(4) {
  color: #b86b19;
  font-weight: 800;
}

.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 0;
  background: var(--bg);
}

.text-btn {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: #fff;
  color: var(--teal);
  font-weight: 800;
}

.selected-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.quote-card {
  padding: 16px;
}

.quote-card.is-added {
  background: var(--gold-soft);
  border: 1px solid rgba(248, 180, 80, 0.75);
}

.price {
  color: #b95f18;
  font-weight: 900;
}

.quote-desc {
  margin-top: 4px;
  color: #8b9994;
  font-size: 13px;
}

.quote-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.spec-select {
  min-width: 0;
  width: 100%;
}

.custom-price-control,
.custom-reference-control {
  display: grid;
  gap: 6px;
  color: #64736f;
  font-size: 13px;
  font-weight: 800;
}

.custom-price-control input,
.custom-reference-control input {
  width: 100%;
  height: 40px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  outline: 0;
}

.custom-price-control input:focus,
.custom-reference-control input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(19, 132, 121, 0.12);
}

.custom-tinting-fee-control {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  color: #44534f;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.custom-tinting-fee-control input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--teal);
}

.qty-stepper {
  display: grid;
  width: 100%;
  grid-template-columns: 42px minmax(56px, 1fr) 42px;
  min-width: 0;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.qty-stepper button,
.qty-stepper input {
  height: 40px;
  border: 0;
  background: #fff;
  color: var(--teal);
  text-align: center;
  font-weight: 800;
  outline: 0;
}

.qty-stepper input {
  border-left: 1px solid rgba(31, 41, 51, 0.1);
  border-right: 1px solid rgba(31, 41, 51, 0.1);
  color: var(--ink);
}

.add-btn {
  display: block;
  width: min(260px, 100%);
  margin: 12px auto 0;
}

.delete-btn {
  background: #f1a768;
}

.summary-toolbar {
  flex-wrap: wrap;
  padding: 14px;
}

.summary-toolbar label {
  display: grid;
  gap: 5px;
  color: #566761;
  font-size: 13px;
  font-weight: 700;
}

.sheet-scroll {
  overflow-x: auto;
  margin-top: 14px;
  background: #fff;
}

.quote-sheet {
  width: 1120px;
  border-left: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
}

.sheet-top,
.sheet-row,
.sheet-total,
.sheet-remark,
.sheet-row.sheet-meta {
  display: grid;
  grid-template-columns: 95px 120px 240px 110px 88px 130px 70px 70px 120px 130px;
}

.sheet-top span,
.sheet-row span,
.sheet-total span,
.sheet-remark span {
  min-height: 34px;
  padding: 7px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  overflow-wrap: anywhere;
}

.sheet-top span {
  background: #fff200;
  border-top: 1px solid var(--line);
  font-weight: 900;
}

.sheet-row.sheet-meta {
  background: #fff200;
  font-weight: 900;
}

.sheet-row.sheet-meta .meta-left {
  grid-column: 1 / span 5;
  background: #fff200;
  text-align: left;
  padding: 7px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-height: 34px;
  overflow-wrap: anywhere;
  display: block;
}

.sheet-row.sheet-meta .meta-right {
  grid-column: 6 / span 5;
  background: #fff200;
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  min-height: 34px;
  overflow-wrap: anywhere;
  display: block;
}

.sheet-top .logistics {
  grid-column: 1 / span 5;
  text-align: left;
}

.sheet-top .delivery {
  grid-column: 6 / span 5;
  text-align: left;
}

.sheet-head span {
  background: #f3f4f6;
  font-weight: 900;
}

.sheet-row .green {
  background: var(--green);
  color: #052e24;
  font-weight: 900;
}

.sheet-total .label {
  grid-column: 1 / span 9;
  text-align: right;
}

.sheet-total .value {
  grid-column: 10 / span 1;
  font-weight: 800;
}

.sheet-remark .label {
  grid-column: 1 / span 1;
  font-weight: 900;
}

.sheet-remark .value {
  grid-column: 2 / span 9;
  min-height: 34px;
  text-align: left;
}

.summary-remark-control,
.summary-address-control {
  min-width: 220px;
}

.summary-remark-control textarea,
.summary-address-control textarea {
  width: 100%;
  min-height: 44px;
  resize: vertical;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.summary-remark-control textarea:focus,
.summary-address-control textarea:focus {
  outline: none;
  border-color: var(--brand, #0f766e);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18);
}

.summary-date-control {
  min-width: 170px;
}

.summary-date-control input {
  width: 100%;
  height: 42px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.summary-date-control input:focus {
  outline: none;
  border-color: var(--brand, #0f766e);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18);
}

.summary-person-control {
  min-width: 180px;
}

.summary-person-control input {
  width: 100%;
  height: 42px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.summary-person-control input:focus {
  outline: none;
  border-color: var(--brand, #0f766e);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18);
}

.summary-export-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.summary-export-actions .export-btn {
  min-width: 150px;
  white-space: nowrap;
}

.notes {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  padding: 16px;
  color: #374151;
  line-height: 1.45;
}

.notes-title {
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
}

.export-canvas {
  position: fixed;
  left: -3000px;
  top: -3000px;
}

.export-preview {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(12, 18, 16, 0.72);
}

.export-preview.is-open {
  display: flex;
}

.export-preview-panel {
  display: grid;
  gap: 12px;
  width: min(980px, 100%);
  max-height: 92vh;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
}

.export-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.export-preview-head strong {
  display: block;
  font-size: 18px;
}

.export-preview-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.export-preview img {
  width: 100%;
  max-height: calc(92vh - 92px);
  object-fit: contain;
  border: 1px solid rgba(31, 41, 51, 0.18);
  background: #fff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 30;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(30, 30, 30, 0.86);
  color: #fff;
  font-size: 14px;
}

@media (max-width: 720px) {
  .hero-content,
  .section-head,
  .sticky-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .quote-category-tabs {
    top: 0;
  }

  .quote-actions {
    width: 100%;
  }

  .selected-bar {
    justify-content: space-between;
  }

  .summary-toolbar {
    display: grid;
    grid-template-columns: minmax(106px, 34%) minmax(0, 1fr);
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }

  .summary-toolbar .text-btn {
    grid-column: 1;
    grid-row: 1;
    min-height: 48px;
    align-self: start;
    font-size: 17px;
  }

  .summary-toolbar label {
    grid-column: 2;
    width: 100%;
    min-width: 0;
  }

  .summary-toolbar label:nth-of-type(1) {
    grid-row: 1;
  }

  .summary-toolbar label:nth-of-type(2) {
    grid-row: 2;
  }

  .summary-toolbar label:nth-of-type(3) {
    grid-row: 3;
  }

  .summary-toolbar label:nth-of-type(4) {
    grid-row: 4;
  }

  .summary-toolbar label:nth-of-type(5) {
    grid-row: 5;
  }

  .summary-toolbar label:nth-of-type(6) {
    grid-column: 1 / span 2;
    grid-row: 6;
  }

  .summary-toolbar label:nth-of-type(7) {
    grid-column: 1 / span 2;
    grid-row: 7;
  }

  .summary-toolbar select {
    width: 100%;
    min-width: 0;
  }

  .summary-toolbar .summary-export-actions {
    grid-column: 1 / span 2;
    grid-row: 8;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    margin-left: 0;
  }

  .summary-toolbar .summary-export-actions .export-btn {
    grid-column: auto;
    grid-row: auto;
    min-width: 0;
    min-height: 48px;
    align-self: end;
    padding: 0 10px;
    font-size: 15px;
    line-height: 1.2;
  }

  .export-preview {
    padding: 10px;
  }

  .export-preview-panel {
    max-height: 94vh;
    padding: 10px;
  }

  .export-preview-head strong {
    font-size: 16px;
  }

  .export-preview-head p {
    font-size: 12px;
  }
}
