body {
  margin: 0;
  background: #f3f5f8;
}
* {
  box-sizing: border-box;
}

#app {
  --qe-bg: light-dark(#f3f5f8, #171d26);
  --qe-surface: light-dark(#fff, #222b37);
  --qe-text: light-dark(#233247, #edf2fa);
  --qe-muted: light-dark(#64748b, #b2c0d3);
  --qe-line: light-dark(#e0e6ed, #405065);
  --qe-brand: light-dark(#235dc1, #a8c7ff);
  --qe-onbrand: light-dark(#fff, #122342);
  --qe-tint: light-dark(#eaf1ff, #2b405e);
  --qe-warn: light-dark(#88520c, #f5d28f);
  --qe-warm: light-dark(#fff7e8, #3a3123);
  --qe-red: light-dark(#b32936, #ffacb4);
  --qe-gap: 18px;
  background: var(--qe-bg);
  color: var(--qe-text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid var(--qe-line);
  border-radius: 14px;
  overflow: hidden;
}
#app * {
  box-sizing: border-box;
}
#app button,
#app input,
#app select,
#app textarea {
  font: inherit;
  color: inherit;
}
#app button {
  padding: 8px 13px;
  border: 1px solid var(--qe-line);
  background: var(--qe-surface);
  border-radius: 7px;
  cursor: pointer;
}
#app button:hover {
  border-color: var(--qe-brand);
}
#app button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#app .primary {
  background: var(--qe-brand);
  border-color: var(--qe-brand);
  color: var(--qe-onbrand);
}
#app .quiet {
  border-color: transparent;
  background: transparent;
  color: var(--qe-brand);
}
#app .selected {
  background: var(--qe-tint);
  color: var(--qe-brand);
  border-color: transparent;
}
#app input,
#app select,
#app textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--qe-line);
  background: var(--qe-surface);
  padding: 9px 10px;
  border-radius: 6px;
}
#app textarea {
  resize: vertical;
}
#app label {
  display: grid;
  gap: 6px;
  color: var(--qe-muted);
}
#app h2,
#app h3,
#app h4,
#app p {
  margin: 0;
}
#app h2 {
  font-size: 22px;
  font-weight: 500;
}
#app h3 {
  font-size: 16px;
  font-weight: 500;
}
#app h4 {
  font-size: 14px;
  font-weight: 500;
}
#app strong {
  font-weight: 500;
}
#app small {
  font-size: 12px;
}
#app .muted {
  color: var(--qe-muted);
}
#app .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 22px;
  background: var(--qe-surface);
  border-bottom: 1px solid var(--qe-line);
}
#app .brand {
  display: flex;
  gap: 11px;
  align-items: center;
}
#app .mark {
  background: var(--qe-brand);
  color: var(--qe-onbrand);
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 500;
}
#app .shell {
  display: grid;
  grid-template-columns: 155px minmax(0, 1fr);
}
#app .side {
  background: var(--qe-surface);
  padding: 22px 12px;
  border-right: 1px solid var(--qe-line);
}
#app .side button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  border-color: transparent;
  padding: 12px;
}
#app main {
  padding: 24px;
  min-width: 0;
}
#app .row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
#app .between {
  justify-content: space-between;
}
#app .heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
#app .tabs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--qe-line);
  padding-bottom: 12px;
  margin-bottom: 18px;
}
#app .tabs button {
  border-color: transparent;
}
#app .panel {
  padding: var(--qe-gap);
  border: 1px solid var(--qe-line);
  border-radius: 9px;
  background: var(--qe-surface);
  margin-bottom: 16px;
}
#app .fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0;
}
#app .wide {
  grid-column: 1/-1;
}
#app .badge {
  display: inline-flex;
  background: var(--qe-tint);
  color: var(--qe-brand);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
}
#app .warning {
  background: var(--qe-warm);
  color: var(--qe-warn);
}
#app .note {
  padding: 11px 14px;
  border-radius: 7px;
  background: var(--qe-warm);
  color: var(--qe-warn);
  margin-bottom: 16px;
}
#app .scroll {
  overflow-x: auto;
}
#app table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
}
#app th {
  font-weight: 400;
  color: var(--qe-muted);
  white-space: nowrap;
  background: var(--qe-bg);
}
#app th,
#app td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--qe-line);
  vertical-align: middle;
}
#app .num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#app .actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}
#app .footer {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  border-top: 1px solid var(--qe-line);
  padding-top: 16px;
  margin-top: 16px;
}
#app details {
  border-top: 1px solid var(--qe-line);
  padding-top: 14px;
  margin-top: 16px;
}
#app summary {
  cursor: pointer;
  color: var(--qe-brand);
}
#app .error {
  color: var(--qe-red);
  margin-top: 12px;
}
#app .toast {
  background: var(--qe-tint);
  color: var(--qe-brand);
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: 7px;
}
#app .crumb {
  font-size: 12px;
  color: var(--qe-muted);
  margin-bottom: 8px;
}
#app .quote-line {
  border-bottom: 1px solid var(--qe-line);
  padding: 14px 0;
}
#app .quote-grid {
  display: grid;
  grid-template-columns: minmax(160px, 2fr) 75px 105px 100px;
  gap: 12px;
  align-items: end;
}
#app .steps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--qe-muted);
  margin-bottom: 18px;
}
#app .product-select {
  max-width: 300px;
}
#app .total {
  display: flex;
  justify-content: flex-end;
  gap: 25px;
  padding: 18px 0;
}
#app .paper {
  padding: 28px;
  background: var(--qe-surface);
  border: 1px solid var(--qe-line);
  border-radius: 6px;
}
#app .paper h2 {
  text-align: center;
  margin: 20px 0;
}
#app .entry-title {
  min-width: 140px;
}
#app button svg {
  width: 16px;
  height: 16px;
}
#app .danger {
  color: var(--qe-red);
}
@media (max-width: 720px) {
  #app .shell {
    grid-template-columns: 1fr;
  }
  #app .side {
    display: flex;
    gap: 6px;
    border-right: 0;
    border-bottom: 1px solid var(--qe-line);
    padding: 9px;
    flex-wrap: wrap;
  }
  #app .side button {
    width: auto;
    margin: 0;
    padding: 9px;
  }
  #app main {
    padding: 16px;
  }
  #app .quote-grid {
    grid-template-columns: 1fr 1fr;
  }
  #app .fields {
    grid-template-columns: 1fr;
  }
  #app .top {
    padding: 14px;
  }
  #app .product-select {
    max-width: 100%;
  }
}
@media (pointer: coarse) {
  #app button {
    min-height: 44px;
  }
  #app input,
  #app select,
  #app textarea {
    font-size: 16px;
  }
}

#app {
  min-height: 100vh;
  border: 0;
  border-radius: 0;
}
#app .shell {
  min-height: calc(100vh - 80px);
}
#app main {
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}
#app .side {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: calc(100vh - 80px);
}
#app .login {
  max-width: 460px;
  margin: 8vh auto;
  padding: 24px;
}
#app .login input {
  margin-top: 6px;
}
#app .login label {
  margin: 18px 0;
}
#app .empty {
  padding: 36px 18px;
  text-align: center;
  color: var(--qe-muted);
}
#app .search {
  max-width: 320px;
}
#app pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  padding: 14px;
  background: var(--qe-bg);
  border-radius: 6px;
}
#app .line-editor {
  padding: 16px 0;
  border-bottom: 1px solid var(--qe-line);
}
#app .quote-grid {
  grid-template-columns: minmax(130px, 2fr) minmax(100px, 1.4fr) 80px 110px auto;
}
#app .stage {
  color: var(--qe-muted);
  padding: 8px 0;
}
#app .data-label {
  overflow-wrap: anywhere;
}
#app .conflict {
  border: 1px solid var(--qe-red);
  padding: 14px;
  margin: 14px 0;
  border-radius: 6px;
}
#app a {
  color: var(--qe-brand);
}
#app .muted-link {
  font-size: 12px;
}
#app .full {
  width: 100%;
}
#app .statusbar {
  min-height: 26px;
}
#app .current {
  background: var(--qe-tint);
}
#app .error:empty {
  display: none;
}
#app th {
  font-weight: 500;
}
#app td {
  overflow-wrap: anywhere;
  max-width: 420px;
}
#app input:focus-visible,
#app button:focus-visible,
#app select:focus-visible,
#app textarea:focus-visible {
  outline: 2px solid var(--qe-brand);
  outline-offset: 2px;
}
#app .quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#app .readonly {
  padding: 8px 0;
}
#app .scroll {
  max-width: 100%;
}
#app .import-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#app .import-columns span {
  background: var(--qe-bg);
  padding: 4px 8px;
  border-radius: 4px;
}
#app .narrow {
  max-width: 720px;
}
#app .paper .num {
  text-align: right;
}
@media (max-width: 720px) {
  #app .side {
    position: static;
    min-height: 0;
  }
  #app .shell {
    min-height: 0;
  }
  #app .quote-grid {
    grid-template-columns: 1fr 1fr;
  }
  #app .login {
    margin: 24px auto;
  }
  #app main {
    padding: 14px;
  }
}
.block {
  display: block;
}
.bom-editor table {
  min-width: 850px;
}
.bom-editor td:first-child {
  min-width: 175px;
}
.bom-editor td input {
  min-width: 90px;
  max-width: 210px;
}
.bom-editor details {
  min-width: 190px;
}
.overlay {
  position: fixed;
  inset: 0;
  background: #12263f88;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  width: min(1100px, 96vw);
  max-height: 90vh;
  overflow: auto;
}
.picker-row {
  padding: 12px;
  border-bottom: 1px solid #e3e8ef;
}
.picker-row input {
  width: auto;
}
.leave-dialog {
  max-width: 560px;
  border: 1px solid #ccd6e3;
}
.leave-dialog::backdrop {
  background: #12263f88;
}
.bom-editor .footer {
  position: sticky;
  bottom: 0;
  background: var(--qe-surface);
  padding: 14px 0;
  z-index: 1;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  .overlay {
    padding: 8px;
  }
  .bom-editor .heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .bom-editor .footer {
    position: static;
  }
}
.bom-editor table button {
  white-space: nowrap;
}
.bom-editor table td:last-child {
  min-width: 65px;
}

/* Keep labels and action controls readable instead of shrinking whole tables. */
#app input[type="checkbox"],
#app input[type="radio"] {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--qe-brand);
}
#app .scroll table {
  min-width: 680px;
}
#app .bom-editor table {
  min-width: 850px;
}
#app td:last-child button {
  white-space: nowrap;
}
#app td:first-child {
  min-width: 165px;
}
#app .total {
  flex-wrap: wrap;
  gap: 8px 24px;
}
#app .picker-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
}
#app .picker-row strong {
  min-width: 90px;
}
#app .picker-row small {
  overflow-wrap: anywhere;
}
#app .bom-editor > .heading:not(:first-child) {
  margin-top: 24px;
}
#app .bom-editor td > input + select,
#app .bom-editor td > select + input,
#app .bom-editor td > select + select {
  margin-top: 8px;
}
.leave-dialog {
  font:
    14px/1.6 "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  width: min(560px, calc(100vw - 32px));
  padding: 24px;
  border-radius: 12px;
  color: CanvasText;
  background: Canvas;
}
.leave-dialog h3 {
  margin: 0;
  font-size: 19px;
}
.leave-dialog .row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.leave-dialog button {
  font: inherit;
  padding: 9px 14px;
  border: 1px solid #8491a5;
  border-radius: 7px;
  cursor: pointer;
}
.leave-dialog .primary {
  color: white;
  background: #235dc1;
  border-color: #235dc1;
}
/* Empty tables need no horizontal scroll; keep the empty-state message visible. */
#app .scroll table:has(td.empty) {
  min-width: 0;
}
#app .scroll table:has(td.empty) thead {
  display: none;
}
#app .scroll td.empty {
  min-width: 0;
  max-width: none;
  padding: 24px 12px;
}
@media (max-width: 720px) {
  #app .scroll:has(tbody td:not(.empty))::before {
    content: "左右滑动查看完整表格";
    display: block;
    color: var(--qe-muted);
    font-size: 12px;
    padding: 8px 0;
  }
}

/* R2 review: horizontal primary navigation for all screen widths. */
#app .shell { display: block; min-height: 0; }
#app .side { position: static; min-height: 0; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 22px; border-right: 0; border-bottom: 1px solid var(--qe-line); }
#app .side button { width: auto; margin: 0; padding: 10px 16px; }
#app .login label.row { display: flex; align-items: center; }
#app .login input[type="checkbox"] { width: auto; margin: 0; }
#app .bom-divider td { padding: 12px 10px; border-bottom: 0; }
#app .bom-divider-content { display: flex; align-items: center; gap: 16px; }
#app .bom-divider hr { flex: 1; margin: 0; border: 0; border-top: 4px solid var(--qe-muted); }

/* Order calculation: keep monetary values intact and inputs compact. */
#app .order-toolbar { margin: 12px 0; }
#app .order-toolbar select { width: min(360px, 100%); }
#app .order-toolbar input { width: 180px; }
#app .order-lines { min-width: 1120px; }
#app .order-lines th, #app .order-lines td { white-space: nowrap; }
#app .order-lines input { width: 100px; min-width: 0; }
#app .order-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; margin: 16px 0; }
#app .order-totals > div { padding: 12px; border: 1px solid var(--qe-line); border-radius: 8px; }
#app .order-totals strong { font-size: 20px; }

/* One operation group per row, aligned with its column heading. */
#app .action-cell { width: 1%; white-space: nowrap; }
#app .cell-actions { display: flex; align-items: center; justify-content: flex-start; gap: 6px; flex-wrap: nowrap; }
#app .cell-actions button { flex: 0 0 auto; margin: 0; white-space: nowrap; }
#app .order-list-row { display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--qe-line); }
#app .order-list-row > div:first-child { overflow-wrap: anywhere; }
@media (max-width: 700px) {
  #app .order-list-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #app .order-list-row .cell-actions { flex-wrap: wrap; }
}

#app .list-toolbar { align-items: flex-end; gap: 12px; margin-bottom: 12px; }
#app .list-toolbar > input { margin: 0; }
#app .list-toolbar > label.row { min-height: 40px; }
#app td:first-child button.quiet { text-align: left; }

/* Inquiry scenarios keep their related actions together. */
#app .order-list-row { grid-template-columns: minmax(0, 1fr) 420px; }
@media (max-width: 900px) { #app .order-list-row { grid-template-columns: minmax(0, 1fr); } #app .order-list-row .cell-actions { flex-wrap: wrap; } }

#app .inquiry-products { margin: 20px 0; padding: 16px 0; border-block: 1px solid var(--qe-line); }
#app .inquiry-product-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; margin-bottom: 14px; }
#app .inquiry-product-row button { margin-bottom: 0; }
@media (max-width: 600px) { #app .inquiry-product-row { grid-template-columns: minmax(0, 1fr) auto; } #app .inquiry-product-row label:first-child { grid-column: 1 / -1; } }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.site-footer {
  margin-top: auto;
  padding: 20px 16px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  color: #526173;
  font: 12px/1.7 "PingFang SC", "Microsoft YaHei", sans-serif;
  text-align: center;
  overflow-wrap: anywhere;
}
.site-footer a {
  color: inherit;
  text-underline-offset: 3px;
}
.site-footer a:hover {
  color: #235dc1;
}
.site-footer a:focus-visible {
  outline: 2px solid #235dc1;
  outline-offset: 4px;
}
