:root {
  color-scheme: light;
  --canvas: #eef2ef;
  --surface: #ffffff;
  --surface-soft: #f5f7f5;
  --ink: #14231c;
  --muted: #64736b;
  --line: #d5dfd8;
  --line-strong: #b9c9bf;
  --primary: #0d6047;
  --primary-dark: #064432;
  --primary-soft: #e2f2ea;
  --accent: #d06b3c;
  --accent-soft: #fff0e9;
  --danger: #b2473d;
  --danger-soft: #faecea;
  --shadow: 0 14px 36px rgba(20, 55, 40, 0.1);
  font-family: "Avenir Next", "Segoe UI Variable", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
select,
input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(23, 107, 69, 0.18);
  outline-offset: 1px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 100vh;
  padding: 24px 14px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 1px 0 0 rgba(20, 55, 40, 0.03), 8px 0 22px rgba(20, 55, 40, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 8px 28px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-size: 19px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.view-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  align-self: auto;
  gap: 6px;
}

.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 48px;
  justify-content: flex-start;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
  transition: color 160ms ease, background 160ms ease;
}

.nav-button::after {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 3px;
  height: auto;
  border-radius: 0 3px 3px 0;
  background: transparent;
  content: "";
}

.nav-button:hover,
.nav-button.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-button.is-active::after {
  background: var(--primary);
}

.nav-button svg,
.icon-text-button svg,
.primary-button svg,
.icon-button svg,
.product-item svg,
.search-field svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.local-status {
  margin-top: auto;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.local-status span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #30a46c;
  box-shadow: 0 0 0 3px #e3f4eb;
}

.product-sidebar {
  position: sticky;
  top: 72px;
  align-self: start;
  min-height: calc(100vh - 72px);
  padding: 24px 12px;
  border-right: 1px solid var(--line);
  background: #f8faf8;
}

.sidebar-label {
  padding: 0 10px 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.product-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 16px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: left;
  background: transparent;
}

.product-item.is-active {
  border-color: #c9ded2;
  background: var(--primary-soft);
}

.product-item + .product-item {
  margin-top: 6px;
}

.product-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 5px;
  color: var(--primary);
  background: var(--surface);
}

.product-item strong,
.product-item small {
  display: block;
}

.product-item strong {
  font-size: 13px;
}

.product-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.product-item > svg {
  color: var(--primary);
}

.sidebar-meta {
  display: flex;
  justify-content: space-between;
  margin: 20px 10px 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.sidebar-meta strong {
  color: var(--ink);
}

.workspace {
  min-width: 0;
  grid-column: 2;
  grid-row: 1;
}

.quote-layout {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 390px;
  align-items: start;
  gap: 0;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
}

.quote-editor {
  min-width: 0;
  padding: 42px 48px 78px;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-heading h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1.2;
}

.icon-text-button,
.primary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-weight: 650;
}

.icon-text-button {
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.icon-text-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.primary-button {
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
}

.primary-button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

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

.icon-button.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.form-section {
  padding: 30px 0 34px;
  border-top: 1px solid var(--line);
}

.form-section h2,
.settings-section h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  font-size: 16px;
}

.form-section h2 > span:first-child {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 11px;
}

.form-grid {
  display: grid;
  gap: 18px;
}

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

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field em {
  color: #8b958f;
  font-style: normal;
  font-weight: 500;
}

.field input,
.field select,
.field textarea,
.setting-field input,
.search-field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
}

.field input,
.field select {
  height: 46px;
  padding: 0 12px;
}

.field-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.field-action-row input {
  min-width: 0;
  flex: 1 1 auto;
}

.sync-quantity-button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--primary);
  border-radius: 5px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.sync-quantity-button:hover {
  color: #fff;
  background: var(--primary);
}

.field textarea {
  min-height: 78px;
  padding: 11px 12px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.setting-field input:focus {
  border-color: var(--primary);
}

.field input[readonly],
.field select:disabled {
  cursor: default;
  color: #59625c;
  background: #eef1ef;
}

.field-wide {
  grid-column: span 2;
}

.compact-check {
  display: flex;
  align-items: center;
  align-self: end;
  gap: 8px;
  min-height: 42px;
  color: var(--ink);
  font-weight: 600;
}

.compact-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.control-group {
  min-width: 0;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.control-group legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

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

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

.segmented.five-segments {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.segment {
  position: relative;
  min-width: 0;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment span {
  display: grid;
  min-height: 44px;
  place-items: center;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.segment input:checked + span {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.segment input:focus-visible + span {
  outline: 3px solid rgba(23, 107, 69, 0.18);
}

.segment.is-disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.process-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 12px;
  margin-top: 20px;
}

.combined-copy-section .combined-process-group {
  grid-column: 1 / -1;
}

.discount-process-group .process-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.transfer-process-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.15fr) minmax(0, 4fr);
  align-items: stretch;
  gap: 12px;
}

.transfer-process-row .segmented.four-segments {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.transfer-process-row > .toggle-row,
.transfer-process-row .segment span {
  min-height: 44px;
}

.transfer-process-row > .toggle-row {
  padding-top: 9px;
  padding-bottom: 9px;
}

.combined-copy-section h2 {
  flex-wrap: wrap;
}

.copy-product-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.copy-product-picker select {
  min-width: 150px;
  height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
}

.order-fields,
.combined-copy-section > .form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.order-services-group .process-list,
.combined-copy-section .combined-process-group .process-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.order-services-group .nested-control-group {
  margin-top: 0;
}

.combined-copy-section .discount-process-group .process-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.process-list > .field {
  align-self: stretch;
}

.process-list > .field.compact-field {
  max-width: 220px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-copy-meta {
  margin: -4px 0 12px;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.process-list.three-items {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-type-group {
  margin-top: 0;
}

.order-fields {
  margin-top: 18px;
}

.roll-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}

.pvc-option-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.read-only-process {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin-top: 18px;
  padding: 0 12px;
  border: 1px solid #c9ded2;
  border-radius: 5px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 650;
}

.read-only-process svg {
  width: 17px;
  height: 17px;
}

.toggle-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.toggle-row:hover {
  border-color: var(--line-strong);
  box-shadow: 0 4px 12px rgba(20, 55, 40, 0.06);
}

.toggle-row:active {
  transform: translateY(1px);
}

.toggle-row > span:first-child {
  min-width: 0;
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row strong {
  font-size: 13px;
}

.toggle-row small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
}

.toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: #bec7c1;
  transition: background 160ms ease;
}

.toggle-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  content: "";
  transition: transform 160ms ease;
}

.toggle-row input:checked + .toggle-track {
  background: var(--primary);
}

.toggle-row input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.toggle-row input:focus-visible + .toggle-track {
  outline: 3px solid rgba(23, 107, 69, 0.18);
}

.toggle-row.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
  background: #f1f3f1;
}

.inline-dimensions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 10px;
  padding: 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}

.inline-dimensions > span {
  padding-bottom: 12px;
  color: var(--muted);
}

.note-field {
  margin-top: 18px;
}

.quote-summary {
  position: sticky;
  top: 96px;
  min-width: 0;
  max-height: calc(100vh - 112px);
  margin: 34px 32px 34px 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-top: 3px solid var(--primary);
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.summary-head strong {
  color: var(--primary);
}

.price-block {
  padding: 22px 18px 20px;
  border-bottom: 1px solid var(--line);
}

.price-block > span,
.price-block > small,
.price-block > strong {
  display: block;
}

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

.price-block > strong {
  margin: 6px 0 4px;
  color: var(--primary-dark);
  font-size: 38px;
  letter-spacing: 0;
  line-height: 1.1;
}

.price-block > small {
  color: var(--muted);
  font-size: 11px;
}

.production-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 8px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.production-metrics div {
  min-width: 0;
  padding: 10px 8px 6px 0;
}

.production-metrics dt {
  color: var(--muted);
  font-size: 10px;
}

.production-metrics dd {
  margin: 4px 0 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.summary-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.summary-section-title h3 {
  margin: 0;
  font-size: 13px;
}

.summary-section-title span {
  color: var(--muted);
  font-size: 10px;
}

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

.breakdown-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 11px;
}

.breakdown-list strong {
  color: var(--ink);
  font-size: 11px;
}

.quantity-table,
.settings-table,
.history-table {
  width: 100%;
  border-collapse: collapse;
}

.quantity-table th,
.quantity-table td {
  height: 30px;
  padding: 0 6px;
  border-bottom: 1px solid #edf0ee;
  font-size: 10px;
  text-align: right;
  white-space: nowrap;
}

.quantity-table th:first-child,
.quantity-table td:first-child {
  text-align: left;
}

.quantity-table th {
  color: var(--muted);
  font-weight: 600;
}

.quantity-table tr.is-current td {
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 700;
}

.summary-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 40px;
  gap: 8px;
  padding: 16px 18px;
}

.summary-actions.no-history {
  grid-template-columns: minmax(0, 1fr) 40px;
}

.validation-panel {
  display: flex;
  gap: 10px;
  margin: 18px;
  padding: 12px;
  border: 1px solid #ecc8c4;
  border-radius: 5px;
  color: var(--danger);
  background: var(--danger-soft);
}

.validation-panel svg {
  width: 20px;
  flex: 0 0 auto;
}

.validation-panel p {
  margin: 0 0 4px;
  font-size: 12px;
}

.summary-empty,
.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.summary-empty {
  min-height: 240px;
  gap: 10px;
}

.summary-empty svg {
  width: 32px;
  height: 32px;
}

.settings-view,
.history-view {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 34px 56px 70px;
}

.history-view.records-view {
  max-width: none;
  padding: 32px 24px 64px;
}

.records-view .page-heading {
  margin-bottom: 24px;
}

.page-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.records-view .heading-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.updates-list {
  display: grid;
  gap: 16px;
}

.update-entry {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.update-entry-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.update-entry-head strong {
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.update-entry h2 {
  margin: 4px 0 0;
  font-size: 1.05rem;
}

.update-entry time {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.update-entry ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

.settings-heading,
.history-heading {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.settings-section {
  padding: 24px 0 28px;
  border-bottom: 1px solid var(--line);
}

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

.settings-help {
  margin: -8px 0 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.setting-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.setting-field > div {
  position: relative;
}

.setting-field input {
  height: 40px;
  padding: 0 42px 0 10px;
}

.setting-field em {
  position: absolute;
  top: 50%;
  right: 10px;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  transform: translateY(-50%);
}

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

.settings-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.history-table-wrap {
  overflow-x: auto;
  scroll-padding-right: 236px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.history-view > .empty-state {
  min-height: 220px;
}

.history-table {
  width: 100%;
  min-width: 2110px;
  table-layout: fixed;
}

.settings-table th,
.settings-table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.history-table th,
.history-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-table th:nth-child(1),
.history-table td:nth-child(1) {
  width: 180px;
  white-space: nowrap;
}

.history-table th:nth-child(2),
.history-table td:nth-child(2) {
  width: 190px;
  white-space: nowrap;
}

.history-table th:nth-child(4),
.history-table td:nth-child(4) {
  width: 140px;
}

.history-table th:nth-child(3),
.history-table td:nth-child(3),
.history-table th:nth-child(9),
.history-table td:nth-child(9) {
  width: 148px;
}

.history-table th:nth-child(6),
.history-table td:nth-child(6) {
  width: 142px;
  white-space: nowrap;
}

.history-table th:nth-child(5),
.history-table td:nth-child(5) {
  width: 96px;
  white-space: nowrap;
}

.history-table th:nth-child(7),
.history-table td:nth-child(7) { width: 64px; }
.history-table th:nth-child(8),
.history-table td:nth-child(8) { width: 86px; }
.history-table th:nth-child(10),
.history-table td:nth-child(10),
.history-table th:nth-child(13),
.history-table td:nth-child(13) { width: 100px; }
.history-table th:nth-child(14),
.history-table td:nth-child(14) { width: 90px; }

.history-table th:nth-child(n+10):nth-child(-n+14),
.history-table td:nth-child(n+10):nth-child(-n+14) {
  text-align: right;
}

.history-table th:last-child,
.history-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  width: 236px;
  background: var(--surface);
  box-shadow: -1px 0 var(--line);
}

.history-table thead th:last-child {
  background: var(--surface-soft);
}

.history-table th:nth-child(15),
.history-table td:nth-child(15) {
  width: 108px;
  white-space: nowrap;
}

.history-table th:nth-child(11),
.history-table td:nth-child(11),
.history-table th:nth-child(12),
.history-table td:nth-child(12) {
  width: 94px;
}

.settings-table th,
.history-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 700;
}

.settings-table td,
.history-table td {
  font-size: 12px;
}

.settings-table tbody tr:last-child td,
.history-table tbody tr:last-child td {
  border-bottom: 0;
}

.table-input {
  display: flex;
  align-items: center;
  width: 126px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
}

.table-input input {
  width: 82px;
  height: 34px;
  padding: 0 8px;
  border: 0;
  background: transparent;
}

.table-input span {
  color: var(--muted);
  font-size: 10px;
}

.tier-range {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.tier-range .table-input {
  width: min(150px, 100%);
}

.tier-add {
  margin-top: 12px;
}

.tier-remove {
  width: 32px;
  height: 32px;
}

.search-field {
  display: flex;
  align-items: center;
  width: 230px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
}

.search-field svg {
  color: var(--muted);
}

.search-field input {
  height: 34px;
  padding: 0 8px;
  border: 0;
  outline: 0;
}

.order-search-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.order-search-bar .search-field { width: 260px; max-width: 100%; }
.order-search-bar .search-field input { min-width: 0; font-size: 13px; }
.order-search-bar .search-field:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.order-search-bar select {
  width: 140px;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.order-search-bar .icon-text-button { min-height: 38px; padding: 0 14px; }

@media (max-width: 560px) {
  .order-search-bar .search-field { width: 100%; }
  .order-search-bar select, .order-search-bar .icon-text-button { min-height: 44px; }
  .order-search-bar .search-field { height: 44px; }
  .order-search-bar .search-field input { height: 40px; }
}

.history-table td strong,
.history-table td small {
  display: block;
}

.history-table td small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.history-edit-input {
  width: 100%;
  min-width: 0;
  height: 34px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.history-money-input {
  width: 100%;
  min-width: 0;
  text-align: right;
}

.history-platform-editor {
  display: grid;
  gap: 5px;
}

.history-platform-select {
  padding-right: 24px;
}

.history-note {
  line-height: 1.45;
}

.history-size {
  line-height: 1.6;
}

.history-edit-input:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(23, 107, 69, 0.18);
  outline-offset: 1px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap;
}

.history-table .row-actions {
  flex-wrap: nowrap;
  align-items: center;
}

.history-table .row-actions > * {
  flex-shrink: 0;
  white-space: nowrap;
}

.history-table tbody tr:hover,
.history-table tbody tr:hover td:last-child,
.order-table tbody tr:hover {
  background: var(--surface-soft);
}

.history-table tr.is-ordered,
.history-table tr.is-ordered td:last-child {
  background: #eef8f1;
}

.history-table tr.is-ordered .history-edit-input:disabled {
  border-color: #d7e4db;
  color: #6a756e;
  background: #f4f8f5;
  cursor: not-allowed;
}

.add-order-button,
.order-added-button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 11px;
}

.order-added-button {
  color: var(--primary);
  border-color: #b8d8c5;
  background: #e7f5ed;
  opacity: 1;
}

.order-management {
  margin-top: 42px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}

.order-management-heading {
  margin-bottom: 16px;
}

.order-management-heading h2 {
  margin: 0;
  font-size: 20px;
}

.order-count {
  color: var(--muted);
  font-size: 12px;
}

.order-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.order-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.order-table th,
.order-table td {
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.order-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 700;
  white-space: normal;
}

.order-table td {
  font-size: 12px;
}

.order-table tbody tr:last-child td {
  border-bottom: 0;
}

.order-table th:nth-child(1),
.order-table td:nth-child(1) { width: 12%; white-space: normal; }
.order-table th:nth-child(2),
.order-table td:nth-child(2) { width: 9%; }
.order-table th:nth-child(3),
.order-table td:nth-child(3) { width: 9%; }
.order-table th:nth-child(4),
.order-table td:nth-child(4) { width: 7%; }
.order-table th:nth-child(5),
.order-table td:nth-child(5) { width: 5%; }
.order-table th:nth-child(6),
.order-table td:nth-child(6) { width: 5.5%; }
.order-table th:nth-child(7),
.order-table td:nth-child(7) { width: 4%; }
.order-table th:nth-child(8),
.order-table td:nth-child(8),
.order-table th:nth-child(9),
.order-table td:nth-child(9) { width: 6%; }
.order-table th:nth-child(10),
.order-table td:nth-child(10) { width: 5%; }
.order-table th:nth-child(11),
.order-table td:nth-child(11),
.order-table th:nth-child(12),
.order-table td:nth-child(12) { width: 5%; }
.order-table th:nth-child(12),
.order-table td:nth-child(12) { width: 4%; }
.order-table th:nth-child(13),
.order-table td:nth-child(13) { width: 5%; }
.order-table th:nth-child(14),
.order-table td:nth-child(14) { width: 4%; }
.order-table th:nth-child(15),
.order-table td:nth-child(15) { width: 5%; }
.order-table th:nth-child(16),
.order-table td:nth-child(16) { width: 8.5%; }
.order-table th:nth-child(n+11):nth-child(-n+14),
.order-table td:nth-child(n+11):nth-child(-n+14) { text-align: right; }

.ship-order-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--primary);
}
.order-added-button:disabled { opacity: 1; }
.tracking-input[aria-invalid="true"] { border-color: var(--danger); }
.order-tracking-readonly { font-variant-numeric: tabular-nums; user-select: text; overflow-wrap: anywhere; }
.editable-amount:has([aria-invalid="true"]) { border-color: var(--danger); background: var(--danger-soft); }

.text-cell-button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  text-align: left;
  font: inherit;
}
.text-cell-button span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-cell-button svg { width: 13px; height: 13px; flex-shrink: 0; color: var(--primary); }
.text-cell-button.is-empty { color: var(--muted); }
.text-cell-button:hover { border-color: var(--primary); background: var(--surface-soft); }
.text-cell-control { display: flex; align-items: stretch; min-width: 0; width: 100%; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); }
.text-cell-control:focus-within, .text-cell-control:hover { border-color: var(--primary); }
.text-cell-control > .text-cell-button { flex: 1; width: 0; border: 0; height: 32px; }
.text-cell-copy { display: grid; place-items: center; flex: 0 0 28px; padding: 0; border: 0; border-radius: 0 4px 4px 0; background: transparent; color: var(--primary); cursor: pointer; }
.text-cell-copy svg { width: 14px; height: 14px; }
.text-cell-copy:hover { background: var(--primary-soft); }
.dispatch-table .text-cell-control > .text-cell-button { width: 0; height: 30px; }

.record-text-dialog {
  width: min(640px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
}
.record-text-dialog::backdrop { background: rgb(20 35 28 / 45%); }
.record-text-dialog form { display: grid; gap: 16px; }
.record-dialog-heading h2 { margin: 0; font-size: 20px; }
.record-dialog-heading p { margin: 8px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.record-text-dialog textarea {
  width: 100%;
  height: min(280px, 40dvh);
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  line-height: 1.7;
  resize: vertical;
}
.record-dialog-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.record-dialog-meta [data-text-count] { white-space: nowrap; font-variant-numeric: tabular-nums; }
.record-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.record-dialog-error { margin: 0; color: var(--danger); font-size: 13px; }
.order-files-dialog { display: none; }
.order-files-dialog[open] { display: grid; gap: 16px; }
.order-files-help, .order-files-empty { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.order-files-list { max-height: 42vh; overflow: auto; border-block: 1px solid var(--line); }
.order-files-empty { padding: 20px 0; }
.order-file-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.order-file-row:last-child { border-bottom: 0; }
.order-file-row > svg { width: 20px; height: 20px; color: var(--primary); flex-shrink: 0; }
.order-file-row > div { flex: 1; min-width: 0; }
.order-file-row strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }
.order-file-row small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.order-file-row a { flex-shrink: 0; color: var(--ink); text-decoration: none; }
.order-file-row a:hover { color: var(--primary); }
.order-file-row .delete-file-button { flex-shrink: 0; color: #b42318; border-color: #e7a19a; }
.order-file-row .delete-file-button:hover:not(:disabled) { background: #fff4f2; }
.order-file-row [aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
@media (max-width: 600px) {
  .order-file-row { gap: 6px; }
  .order-file-row .icon-text-button { padding: 7px; gap: 4px; font-size: 12px; }
  .order-file-row > svg { width: 16px; height: 16px; }
}
.order-files-status { margin: 0; font-size: 13px; color: var(--primary); overflow-wrap: anywhere; }
.order-files-status:empty { display: none; }
.order-files-button:disabled { cursor: default; }
.order-files-button.has-downloads { color: #b42318; border-color: #e7a19a; background: #fff4f2; }
.order-files-button.has-downloads:hover { color: #b42318; background: #ffe8e4; }
.file-download-state { color: #b42318; font-weight: 600; }
.order-files-dropzone { display: grid; justify-items: center; gap: 8px; padding: 22px 12px; border: 1px dashed var(--line-strong); border-radius: 6px; color: var(--primary); background: var(--surface-soft); font: inherit; font-size: 13px; }
.order-files-dropzone svg { width: 24px; height: 24px; }
.order-files-dropzone small { color: var(--muted); font-size: 12px; }
.order-files-dropzone:hover, .order-files-dropzone.is-dragover, .order-files-button.is-dragover { border-color: var(--primary); background: var(--primary-soft); outline: 2px solid var(--primary); outline-offset: 2px; }
.order-files-dialog [data-download-files] { color: var(--ink); text-decoration: none; }
.order-files-dialog [data-download-files][aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.order-files-dialog .record-dialog-actions { flex-wrap: wrap; }
.order-file-thumbnail { flex: 0 0 48px; width: 48px; height: 48px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface-soft); cursor: zoom-in; }
.order-file-thumbnail img { display: block; width: 100%; height: 100%; object-fit: contain; }
.order-file-thumbnail:hover { border-color: var(--primary); }
.order-file-thumbnail[hidden], .order-image-preview[hidden] { display: none; }
.order-image-preview { padding: 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; min-width: 0; }
.order-image-preview > img { display: block; width: 100%; height: auto; max-height: min(24dvh, 240px); object-fit: contain; background: var(--surface-soft); }
.order-image-preview > div { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding-top: 10px; }
.order-image-preview [data-preview-name] { min-width: 0; max-height: 3.6em; overflow: auto; overflow-wrap: anywhere; font-size: 13px; line-height: 1.8; }
.order-image-preview button { flex-shrink: 0; }
@media (min-width: 1200px) {
  .order-image-preview[popover] { position: fixed; inset: 24px 24px auto auto; margin: 0; width: min(520px, calc((100vw - 640px) / 2 - 40px)); }
  .order-image-preview[popover] > img { max-height: calc(100dvh - 160px); }
}
@media (max-width: 540px) {
  .order-file-thumbnail { flex-basis: 36px; width: 36px; height: 40px; }
  .order-file-row > svg { display: none; }
}

.record-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; padding: 12px 0; }
.pagination-summary { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pagination-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.pagination-controls label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.pagination-controls select { padding: 8px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--ink); background: var(--surface); }
.pagination-position { min-width: 46px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .record-pagination { gap: 12px; }
  .pagination-controls { width: 100%; gap: 8px; }
  .pagination-controls label { width: 100%; }
  .pagination-controls button { flex: 1; justify-content: center; }
}

.order-import-dialog {
  width: min(1080px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
}
.order-import-dialog::backdrop { background: rgb(20 35 28 / 45%); }
.import-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.import-heading h2 { margin: 0; font-size: 22px; }
.import-heading p, .import-help, .import-explanation, .import-file-name { color: var(--muted); font-size: 13px; line-height: 1.7; }
.import-heading p { margin: 8px 0 0; }
.import-heading > button { flex-shrink: 0; }
.import-upload { padding: 24px; background: var(--surface-soft); border: 1px dashed var(--line-strong); border-radius: 8px; }
.import-upload label { display: block; font-weight: 700; font-size: 16px; }
.import-upload p { color: var(--muted); }
.import-upload input { display: block; width: 100%; margin-top: 20px; }
.import-upload input::file-selector-button { padding: 9px 14px; margin-right: 12px; border: 1px solid var(--line-strong); border-radius: 5px; background: white; color: var(--primary); cursor: pointer; }
.import-explanation { margin-top: 24px; }
.import-settings { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 16px; }
.import-column-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 24px 0; }
.import-settings label, .import-column-grid label { display: grid; gap: 7px; font-size: 13px; min-width: 0; }
.order-import-dialog select, .order-import-dialog input[type="text"] { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--ink); }
.import-file-name { overflow-wrap: anywhere; }
.import-summary { font-size: 15px; color: var(--primary); font-weight: 600; }
.import-preview-wrap { overflow: auto; max-height: 42dvh; border: 1px solid var(--line); border-radius: 6px; }
.import-preview-table { width: 100%; min-width: 1100px; border-collapse: collapse; font-size: 12px; text-align: left; }
.import-preview-table th { position: sticky; top: 0; background: var(--surface-soft); z-index: 1; font-weight: 500; }
.import-preview-table th, .import-preview-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.import-preview-table th, .import-preview-table td:not(:last-child) { white-space: nowrap; }
.import-preview-table td:nth-child(2), .import-preview-table td:nth-child(4) { font-variant-numeric: tabular-nums; }
.import-preview-table td:last-child { min-width: 260px; overflow-wrap: anywhere; }
.import-preview-table th:nth-child(7) { min-width: 240px; }
.import-result-error, .import-error { color: var(--danger); }
.import-result-create, .import-result-update { color: var(--primary); font-weight: 600; }
.import-result-skip { color: var(--muted); }
.import-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.import-error { margin: 20px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.order-product-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) {
  .order-import-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); padding: 18px; }
  .import-heading { gap: 12px; margin-bottom: 20px; }
  .import-heading h2 { font-size: 20px; }
  .import-settings, .import-column-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .import-upload { padding: 18px; }
  .import-actions { justify-content: stretch; }
  .import-actions button { flex: 1; }
  .order-product-cell { max-width: none; white-space: normal; overflow-wrap: anywhere; }
}

.editable-amount {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  width: 120px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-bottom: 1px dashed var(--line-strong);
  border-radius: 4px;
  color: var(--primary);
  cursor: text;
}

.editable-amount:hover,
.editable-amount:focus-within {
  border: 1px solid var(--primary);
  background: var(--surface);
}

.editable-amount:focus-within {
  outline: 2px solid var(--primary-soft);
  outline-offset: 1px;
}

.editable-amount svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.editable-amount .order-cost-input {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: right;
  font: inherit;
  font-weight: 650;
}

.order-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 110px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
}

.order-empty svg {
  width: 28px;
  height: 28px;
  color: var(--primary);
}

.order-empty strong {
  display: block;
  color: var(--ink);
}

.order-empty p {
  margin: 4px 0 0;
  font-size: 12px;
}

/* Desktop keeps readable columns and horizontal scrolling; mobile uses cards. */
@media (max-width: 860px) {
  .table-scroll-hint { display: none; }

  .history-table-wrap {
    border: 0;
    background: transparent;
    scroll-padding-right: 0;
  }

  .history-table,
  .history-table tbody {
    display: block;
    min-width: 0;
  }

  .history-table thead {
    display: none;
  }

  .history-table tr {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
  }

  .history-table td {
    display: block;
    min-width: 0;
    width: auto !important;
    padding: 10px;
    border-right: 1px solid var(--line);
    white-space: normal;
    text-align: left !important;
  }

  .history-table td:last-child {
    position: static;
    grid-column: 1 / -1;
    box-shadow: none;
  }

  .history-table .row-actions { justify-content: flex-start; }
  .history-table .history-money-input { text-align: left; }

  .history-table td:nth-child(1),
  .history-table td:nth-child(2) {
    white-space: nowrap;
  }

  .history-table td::before {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
  }

  .history-table tbody tr:last-child td:not(:last-child) {
    border-bottom: 1px solid var(--line);
  }

}

@media (max-width: 1200px) {
  .order-table-wrap {
    border: 0;
    background: transparent;
  }

  .order-table,
  .order-table tbody {
    display: block;
    min-width: 0;
  }

  .order-table thead {
    display: none;
  }

  .order-table tr {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
  }

  .order-table tr:last-child {
    margin-bottom: 0;
  }

  .order-table td {
    display: block;
    width: auto !important;
    min-width: 0;
    padding: 10px;
    border-right: 1px solid var(--line);
    text-align: left !important;
  }


  .order-table td::before {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
  }

  .order-table tbody tr:last-child td:not(:last-child) {
    border-bottom: 1px solid var(--line);
  }
}

.user-role-picker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.user-role-picker select {
  min-height: 32px;
  padding: 4px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.row-actions .icon-button {
  width: 32px;
  height: 32px;
}

.row-actions svg {
  width: 15px;
  height: 15px;
}

.empty-state {
  min-height: 420px;
  align-content: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.empty-state > svg {
  width: 38px;
  height: 38px;
  color: #9da7a1;
}

.empty-state h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 16px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  min-width: 180px;
  padding: 11px 15px;
  border: 1px solid #b8d8c5;
  border-radius: 5px;
  color: var(--primary-dark);
  background: #edf8f1;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast[data-tone="error"] {
  border-color: #ecc8c4;
  color: var(--danger);
  background: var(--danger-soft);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 176px minmax(0, 1fr);
  }

  .topbar {
    padding-right: 10px;
    padding-left: 10px;
  }

  .quote-layout {
    grid-template-columns: minmax(460px, 1fr) 330px;
  }

  .order-fields,
  .combined-copy-section > .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quote-editor,
  .settings-view,
  .history-view {
    padding-right: 28px;
    padding-left: 28px;
  }

  .quote-summary {
    margin-right: 18px;
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    min-height: 0;
    padding: 12px 14px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    margin-right: auto;
  }

  .brand small,
  .local-status {
    display: none;
  }

  .view-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    flex-direction: row;
    align-self: stretch;
    overflow-x: auto;
    gap: 2px;
  }

  .cloud-account {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
  }

  .nav-button {
    flex: 1 0 auto;
    flex-direction: column;
    justify-content: center;
    min-width: 44px;
    min-height: 56px;
    padding: 6px 4px;
    gap: 4px;
    font-size: 11px;
    white-space: nowrap;
  }

  .nav-button::after {
    right: 6px;
    top: auto;
    bottom: 0;
    left: 6px;
    width: auto;
    height: 3px;
    border-radius: 3px 3px 0 0;
  }

  .product-sidebar {
    position: static;
    display: flex;
    min-height: 0;
    padding: 9px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 8px;
    overflow-x: auto;
  }

  .sidebar-label,
  .sidebar-meta {
    display: none;
  }

  .product-item {
    width: 184px;
    flex: 0 0 184px;
    min-height: 48px;
  }

  .product-item + .product-item {
    margin-top: 0;
  }

  .quote-layout {
    display: block;
  }

  .quote-editor,
  .settings-view,
  .history-view {
    padding: 26px 20px 50px;
  }

  .history-view.records-view { padding: 24px 16px 48px; }

  .quote-summary {
    position: static;
    max-height: none;
    margin: 0 20px 40px;
  }

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

  .order-services-group .process-list,
  .combined-copy-section .combined-process-group .process-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .discount-process-group .process-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .combined-copy-section .discount-process-group .process-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .material-settings {
    grid-column: auto;
  }

  .history-heading {
    align-items: flex-start;
  }

  .history-heading .heading-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }


}

@media (max-width: 560px) {
  .brand strong {
    font-size: 13px;
  }

  .page-heading {
    align-items: flex-start;
    gap: 14px;
  }

  .page-heading h1 {
    font-size: 22px;
  }

  .two-cols,
  .process-list,
  .process-list.three-items,
  .roll-settings,
  .setting-fields,
  .order-fields,
  .combined-copy-section > .form-grid {
    grid-template-columns: 1fr;
  }

  .combined-copy-section .combined-process-group .process-list,
  .discount-process-group .process-list {
    grid-template-columns: 1fr;
  }

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

  .transfer-process-row .segmented.four-segments {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .copy-product-picker {
    flex-basis: 100%;
    margin-left: 40px;
  }

  .field-wide,
  .inline-dimensions {
    grid-column: auto;
  }

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

  .segmented.two-segments,
  .segmented.four-segments,
  .segmented.five-segments {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segment span {
    min-height: 38px;
  }

  .inline-dimensions {
    grid-template-columns: 1fr 14px 1fr;
  }

  .settings-heading,
  .history-heading {
    display: block;
  }

  .heading-actions {
    margin-top: 16px;
  }

  .history-heading .heading-actions {
    justify-content: flex-start;
  }

  .search-field {
    width: 100%;
  }

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

  .history-table td:nth-child(1),
  .history-table td:nth-child(2),
  .order-table td:nth-child(1) {
    grid-column: 1 / -1;
  }

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

  .history-table td[data-label="工艺"],
  .history-table td[data-label="操作"],
  .order-table td[data-label="尺寸(mm)"],
  .order-table td[data-label="工艺"],
  .order-table td[data-label="备注"],
  .order-table td[data-label="可打印文件"],
  .order-table td[data-label="快递单号"],
  .order-table td[data-label="产品"],
  .order-table td[data-label="数量"],
  .order-table td[data-label="加入时间"] {
    grid-column: 1 / -1;
  }
}

.read-only-process[hidden] { display: none; }

.dispatch-table-wrap { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.dispatch-table { width: 100%; min-width: 1632px; table-layout: fixed; border-collapse: collapse; }
/* Keep customer and short fields compact; share spare width between craft/notes.
   External CSS also lets these widths apply under the production CSP. */
.dispatch-col-order-no { width: 224px; }
.dispatch-col-tracking { width: 120px; }
.dispatch-col-customer { width: 156px; }
.dispatch-col-craft, .dispatch-col-note { width: auto; }
.dispatch-col-platform { width: 80px; }
.dispatch-col-product { width: 76px; }
.dispatch-col-size { width: 120px; }
.dispatch-col-quantity { width: 60px; }
.dispatch-col-files { width: 96px; }
.dispatch-col-deal { width: 70px; }
.dispatch-col-cost { width: 76px; }
.dispatch-col-ship-date { width: 120px; }
.dispatch-col-added { width: 86px; }
.dispatch-col-action { width: 150px; }
.dispatch-table th, .dispatch-table td { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dispatch-table th { color: var(--muted); background: var(--surface-soft); font-size: 11px; font-weight: 700; }
.dispatch-table tbody tr:last-child td { border-bottom: 0; }
.dispatch-table tbody tr:hover td { background: var(--surface-soft); }
.dispatch-table th:nth-child(12), .dispatch-table th:nth-child(13), .dispatch-table td[data-label="成交价"], .dispatch-table td[data-label="成本价"] { text-align: right; }
.dispatch-table .history-edit-input, .dispatch-table .text-cell-button { width: 100%; min-width: 0; max-width: 100%; height: 32px; padding: 0 6px; font-size: 12px; }
.dispatch-table .text-cell-button { gap: 4px; }
.dispatch-table .text-cell-button span { white-space: nowrap; }
.clipboard-fallback { position: fixed; opacity: 0; }
.order-number-cell { display: flex; align-items: center; gap: 4px; }
.order-number-edit, .order-number-readonly { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.order-number-edit { display: flex; align-items: center; gap: 4px; padding: 6px 0; border: 0; border-bottom: 1px dashed var(--line-strong); border-radius: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; }
.order-number-edit strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-number-edit svg { width: 12px; height: 12px; flex-shrink: 0; color: var(--primary); }
.order-number-copy { flex-shrink: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--primary); font-size: 11px; padding: 5px 4px; }
.order-number-edit:hover, .order-number-copy:hover { background: var(--surface-soft); }
.order-recipient-dialog { width: min(680px, calc(100% - 32px)); }
.recipient-paste { display: grid; gap: 8px; }
.recipient-paste > button { justify-self: start; }
.order-recipient-dialog .recipient-paste textarea { height: 82px; min-height: 68px; }
.recipient-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.recipient-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.recipient-fields label { display: grid; gap: 6px; min-width: 0; }
.recipient-wide { grid-column: 1 / -1; }
.recipient-fields input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; }
.order-recipient-dialog .recipient-fields textarea { min-height: 70px; height: 70px; padding: 8px 10px; }
.recipient-preview { padding: 12px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; }
.recipient-preview > span, .recipient-paste > label, .recipient-fields label { font-size: 12px; font-weight: 700; }
.recipient-preview pre { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 13px; line-height: 1.7; }
.dispatch-table .editable-amount { width: 100%; min-width: 0; height: 32px; padding: 0 3px; gap: 2px; }
.dispatch-table .order-cost-input { width: 100%; min-width: 0; font-size: 12px; }
.dispatch-table th:last-child, .dispatch-table td:last-child { position: sticky; right: 0; z-index: 1; background: var(--surface); box-shadow: -1px 0 var(--line); text-align: center; }
.dispatch-table th:last-child { background: var(--surface-soft); }
.dispatch-table .ship-order-button { display: flex; justify-content: center; width: 100%; margin: auto; height: 34px; min-height: 34px; gap: 7px; padding: 0 12px; }
.order-fulfillment-status { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; font-size: 11px; }
.order-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.dispatch-table .order-actions .ship-order-button { flex: 1 0 66px; width: auto; padding-inline: 8px; }
.order-refund-button { white-space: nowrap; }
.order-refund-button.has-refund { color: var(--danger); border-color: var(--danger); }
.dispatch-table .order-refund-button { min-height: 34px; padding: 0 7px; font-size: 11px; gap: 3px; }
.dispatch-table .order-refund-button svg { width: 12px; height: 12px; }
.dispatch-table .order-refund-button.has-refund svg { display: none; }

/* Completed orders fit the workspace; let long identifiers wrap rather than
   hiding a column or forcing the whole page wider than the viewport. */
.orders-view { min-width: 0; }
.order-table .order-product-cell { max-width: none; overflow: visible; white-space: normal; text-overflow: clip; }
.order-table .text-cell-button { min-width: 0; width: 100%; padding: 0 4px; gap: 3px; font-size: 12px; }
.order-table .text-cell-control > .text-cell-button { width: 0; }
.order-table .text-cell-copy { flex-basis: 24px; }
.order-table .order-files-button { min-height: 32px; height: auto; padding-block: 5px; }
.order-table .order-files-button span { min-width: 0; overflow: visible; white-space: normal; text-overflow: clip; overflow-wrap: anywhere; }
.order-table .order-files-button svg { width: 12px; height: 12px; }
.order-table .editable-amount { width: 100%; min-width: 0; padding-inline: 2px; gap: 2px; }
.order-table .order-cost-input { font-size: 12px; }
.order-table .order-actions { display: grid; gap: 5px; }
.order-table .order-actions button { width: 100%; min-width: 0; min-height: 30px; padding: 4px 3px; gap: 3px; font-size: 11px; white-space: normal; }
.order-table .order-actions button svg { width: 12px; height: 12px; flex-shrink: 0; }
@media (min-width: 1201px) and (max-width: 1600px) {
  .order-table .order-files-button svg { display: none; }
  .order-table .editable-amount svg { display: none; }
}
@media (max-width: 1200px) {
  .order-table td[data-label="操作"] { grid-column: 1 / -1; }
  .order-table .order-actions { display: flex; flex-wrap: wrap; }
  .order-table .order-actions button { width: auto; min-height: 40px; padding: 6px 12px; font-size: 12px; }
  .order-table .editable-amount { max-width: 150px; }
}

.manual-order-dialog { width: min(720px, calc(100% - 32px)); }
.manual-order-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.manual-order-fields label { display: grid; gap: 7px; min-width: 0; font-size: 13px; }
.manual-wide { grid-column: 1 / -1; }
.manual-order-fields input, .manual-order-fields select { width: 100%; min-width: 0; height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.manual-order-fields input[readonly] { background: var(--surface-soft); }
.manual-order-dialog .manual-order-fields textarea { min-height: 72px; height: 72px; padding: 8px 10px; font: inherit; }
.manual-order-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.manual-order-error { margin: 0; color: var(--danger); font-size: 13px; overflow-wrap: anywhere; }
.manual-original-order { display: grid; gap: 7px; min-width: 0; }
.manual-original-search { display: flex; gap: 8px; align-items: center; }
.manual-original-search > input { flex: 1; }
.manual-original-search > button { flex: 0 0 auto; min-height: 40px; white-space: nowrap; }
.manual-original-status[data-tone="success"] { color: var(--primary-dark); }
.manual-original-status[data-tone="error"] { color: var(--danger); }
.manual-original-recipient { padding: 8px 10px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; }
.manual-order-fields :is(input, textarea):disabled { color: var(--muted); background: var(--surface-soft); opacity: 1; }
.manual-order-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
@media (max-width: 600px) {
  .manual-order-dialog { padding: 18px; }
  .manual-order-fields { grid-template-columns: minmax(0, 1fr); }
  .manual-order-fields input, .manual-order-fields select, .manual-order-dialog button { min-height: 44px; }
  .manual-order-actions button { flex: 1; }
  .order-table .order-actions button { min-height: 44px; }
}

.order-refund-dialog[open] { display: grid; gap: 20px; }
.order-refund-dialog h3 { margin: 0; font-size: 15px; }
.refund-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding-block: 14px; border-block: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.refund-totals dt { color: var(--muted); font-size: 12px; }
.refund-totals dd { margin: 6px 0 0; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.refund-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.refund-fields label, .refund-history label { display: grid; gap: 7px; font-size: 13px; }
.refund-wide { grid-column: 1 / -1; }
.refund-fields input, .refund-fields select, .refund-history input { min-width: 0; width: 100%; height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; }
.refund-fields input[readonly] { background: var(--surface-soft); }
.order-refund-dialog .refund-fields textarea { height: 76px; min-height: 76px; font: inherit; }
.refund-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.refund-effect { margin: 0; padding: 12px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; line-height: 1.7; }
.refund-confirm { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.7; }
.refund-confirm input { flex: 0 0 auto; margin-top: 4px; }
.refund-history { display: grid; gap: 12px; }
.refund-history-item { padding-block: 12px; border-bottom: 1px solid var(--line); }
.refund-history-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.refund-history-line time { margin-left: auto; color: var(--muted); font-size: 12px; }
.refund-status { color: var(--danger); font-size: 12px; }
.refund-history-item > p { margin: 8px 0; font-size: 13px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.refund-history-item > small { color: var(--muted); }
.refund-history-item summary { width: fit-content; margin-top: 10px; padding-block: 6px; color: var(--primary); font-size: 12px; cursor: pointer; text-underline-offset: 3px; }
.refund-history-item form { margin-top: 10px; }
.refund-history-item form button { justify-self: start; }
.refund-file-links { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 13px; }
.order-refund-dialog .record-dialog-actions { flex-wrap: wrap; }
@media (max-width: 600px) {
  .order-refund-dialog { padding: 18px; }
  .refund-totals { gap: 8px; }
  .refund-totals dd { font-size: 15px; }
  .refund-fields { grid-template-columns: 1fr; }
  .refund-fields input, .refund-fields select, .refund-history input, .order-refund-dialog button { min-height: 44px; }
  .refund-history-line time { width: 100%; margin-left: 0; }
}
.shipping-date { height: 34px; border: 1px solid #b5c9c2; border-radius: 4px; background: #fff; }
.shipping-date > button { display: flex; align-items: center; justify-content: space-between; gap: 4px; width: 100%; height: 100%; padding: 0 6px; border: 0; border-radius: 3px; background: transparent; color: inherit; font: inherit; font-size: 11px; }
.shipping-date svg { flex-shrink: 0; width: 14px; height: 14px; }
.shipping-date[data-shipping-urgency="urgent"] { background: #fff0ef; border-color: #d87870; color: #a92c28; }
.shipping-date:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.shipping-legend { color: var(--muted); }
.shipping-date-dialog { width: min(340px, calc(100vw - 32px)); padding: 18px; }
.shipping-calendar-heading, .shipping-calendar-nav, .shipping-calendar-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shipping-calendar-heading { margin-bottom: 12px; }
.shipping-calendar-nav { margin-bottom: 10px; }
.shipping-calendar-nav select { min-width: 0; height: 34px; padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
.shipping-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.shipping-calendar-grid button { height: 36px; padding: 0; border: 1px solid transparent; border-radius: 4px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
.shipping-calendar-grid button:hover { background: var(--primary-soft); }
.shipping-calendar-grid button[aria-current="date"] { border-color: var(--primary); }
.shipping-calendar-grid button[aria-pressed="true"] { color: #fff; background: var(--primary); }
.shipping-weekday { padding: 6px 0; color: var(--muted); font-size: 12px; text-align: center; }
.shipping-calendar-actions { margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--line); }
/* Compact quick quote: keep each desktop copy on one line. */
.compact-quote-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 274px;
  gap: 0 24px;
  max-width: 1880px;
  padding: 22px 28px 28px;
}
.compact-quote-layout .quote-editor { padding: 0; }
.compact-quote-heading { grid-column: 1 / -1; margin-bottom: 15px; }
.compact-quote-heading h1 { font-size: 25px; }
.compact-quote-heading .icon-text-button { min-height: 34px; padding: 0 12px; font-size: 13px; }
.compact-quote-layout .field { gap: 5px; font-size: 12px; font-weight: 600; }
.compact-quote-layout .field input,
.compact-quote-layout .field select,
.compact-inline-field input,
.compact-inline-field select {
  min-width: 0;
  height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
}
.compact-order-info { padding: 14px 16px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.compact-order-fields { display: grid; grid-template-columns: 1.05fr 1.05fr 78px 1.35fr; gap: 12px; }
.compact-order-fields .note-field { margin-top: 0; }
.compact-order-fields .field > span { color: var(--ink); }
.compact-order-fields .field em { margin-left: 4px; font-size: 11px; color: var(--muted); }
.compact-order-services { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.compact-service-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; }
.compact-service-label { color: var(--muted); font-size: 12px; }
.compact-quote-check { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; white-space: nowrap; cursor: pointer; font-size: 12px; font-weight: 400; }
.compact-quote-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.compact-quote-check:has(input:disabled) { color: #7c887f; cursor: not-allowed; }
.compact-quote-check input:disabled { cursor: not-allowed; }
.compact-inline-field { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 12px; white-space: nowrap; }
.compact-inline-field select { width: 178px; font-size: 12px; }
.compact-inline-field input { width: 84px; }
.compact-service-toolbar .compact-inline-field select { width: 155px; height: 29px; padding-top: 3px; padding-bottom: 3px; }
.compact-service-toolbar .compact-inline-field input { height: 29px; }
.compact-service-details { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 12px; margin-top: 12px; }
.compact-service-hint { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 11px; }
.compact-copies-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 39px; }
.compact-copies-heading h2 { margin: 0; font-size: 14px; }
.compact-copies-heading h2 span { margin-left: 7px; color: var(--muted); font-size: 12px; font-weight: 400; }
.compact-text-button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 0; border: 0; background: transparent; color: var(--primary); font-size: 12px; }
.compact-text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.compact-text-button svg, .compact-add-copy svg { width: 16px; height: 16px; }
.compact-copy { display: flex; align-items: flex-end; gap: 12px; min-width: 0; margin-bottom: 10px; padding: 12px; border: 1px solid var(--line); border-top: 2px solid #d76b2b; border-radius: 4px; background: var(--surface); }
.compact-copy-number { flex: 0 0 48px; margin: 0; color: #984816; font-size: 12px; font-weight: 750; line-height: 33px; white-space: nowrap; }
.compact-product { flex: 0 0 104px; }
.compact-product-value { display: flex; align-items: center; height: 33px; color: var(--ink); white-space: nowrap; font-size: 13px; font-weight: 400; }
.compact-copy .field { color: var(--muted); font-size: 11px; font-weight: 500; }
.compact-copy .field input, .compact-copy .field select { height: 33px; }
.compact-copy .compact-product select { padding: 5px 6px; }
.compact-copy-fields { display: grid; flex: 0 0 auto; grid-template-columns: 74px 74px 88px 150px; gap: 8px; min-width: 0; }
.compact-copy-fields.without-material { grid-template-columns: 74px 74px 88px; }
.compact-quote-input { display: block; position: relative; }
.compact-quote-input > span { position: absolute; top: 8px; right: 8px; color: var(--muted); font-size: 11px; pointer-events: none; }
.compact-copy-fields .compact-quote-input input { padding-right: 30px; font-variant-numeric: tabular-nums; appearance: textfield; -moz-appearance: textfield; }
.compact-copy-fields input[type="number"]::-webkit-inner-spin-button,
.compact-copy-fields input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.compact-process { flex: 0 0 auto; min-width: 0; margin: 0 0 0 auto; padding: 0; border: 0; }
.compact-process legend { padding: 0; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 500; }
.compact-process-options { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-height: 33px; }
.compact-process-options .compact-quote-check { min-height: 33px; }
.compact-process-options select { height: 33px; }
.compact-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.compact-add-copy { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 35px; border: 1px dashed #9bb6a6; border-radius: 4px; background: transparent; color: var(--primary); font-size: 12px; }
.compact-add-copy:hover { background: var(--primary-soft); }
.compact-quote-layout .quote-summary { position: sticky; top: 16px; max-height: calc(100vh - 32px); margin: 0; border: 1px solid var(--line); border-radius: 6px; box-shadow: none; }
.compact-quote-layout .summary-head { padding: 16px 18px 0; border: 0; font-size: 13px; }
.compact-quote-layout .summary-head > span { color: var(--ink); font-size: 15px; font-weight: 700; }
.compact-quote-layout .summary-head strong { font-size: 11px; font-weight: 500; }
.compact-quote-layout .price-block { margin: 0 18px; padding: 16px 0; }
.compact-quote-layout .price-block > strong { font-size: 32px; }
.compact-summary-metrics { display: grid; gap: 9px; margin: 0 18px; padding: 16px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.compact-summary-metrics > div { display: flex; justify-content: space-between; gap: 10px; }
.compact-summary-metrics dt { color: var(--muted); }
.compact-summary-metrics dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.compact-summary-copy { margin: 0 18px; border-bottom: 1px solid var(--line); }
.compact-summary-copy > summary { display: flex; align-items: center; gap: 7px; padding: 11px 0; list-style: none; cursor: pointer; font-size: 12px; }
.compact-summary-copy > summary::-webkit-details-marker { display: none; }
.compact-summary-copy > summary > span { flex: 1; min-width: 0; }
.compact-summary-copy > summary > strong { white-space: nowrap; font-size: 12px; font-variant-numeric: tabular-nums; }
.compact-summary-copy > summary::after { content: ""; flex: 0 0 6px; width: 6px; height: 6px; border-right: 1px solid var(--muted); border-bottom: 1px solid var(--muted); transform: rotate(45deg); margin-top: -3px; }
.compact-summary-copy[open] > summary::after { transform: rotate(225deg); margin-top: 2px; }
.compact-summary-copy .summary-copy-meta { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.compact-summary-copy .breakdown-list { padding-bottom: 12px; }
.compact-summary-production { margin: 0 18px; font-size: 12px; color: var(--muted); }
.compact-summary-production > summary { padding-top: 12px; cursor: pointer; }
.compact-summary-production .production-metrics { padding: 4px 0; border-bottom: 0; }
.compact-quote-layout .summary-actions { grid-template-columns: minmax(0, 1fr) 40px; }
.compact-quote-layout .summary-actions.no-history { grid-template-columns: minmax(0, 1fr); }
.compact-quote-layout .summary-actions .primary-button, .compact-quote-layout .summary-actions .icon-button { min-height: 34px; height: 34px; font-size: 13px; }
.compact-summary-copy > summary:focus-visible, .compact-summary-production > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (min-width: 1600px) {
  .compact-quote-layout { grid-template-columns: minmax(0, 1fr) 290px; column-gap: 28px; padding: 24px 32px 30px; }
  .compact-copy { gap: 14px; padding: 12px 14px; }
  .compact-product { flex-basis: 120px; }
  .compact-copy-fields { grid-template-columns: 84px 84px 96px 180px; gap: 10px; }
  .compact-copy-fields.without-material { grid-template-columns: 84px 84px 96px; }
  .compact-process-options { gap: 12px; }
  .compact-process-options .compact-quote-check { gap: 6px; }
}
@media (max-width: 1439px) {
  .compact-quote-layout { grid-template-columns: minmax(0, 1fr); row-gap: 18px; }
  .compact-quote-heading { margin-bottom: 0; }
  .compact-quote-layout .quote-summary { position: static; max-height: none; }
  .compact-quote-layout .summary-actions { max-width: 380px; }
}
@media (max-width: 1199px) {
  .compact-quote-layout { padding: 20px; }
  .compact-copy { display: grid; grid-template-columns: 48px 120px minmax(0, 1fr); align-items: end; gap: 10px 12px; }
  .compact-copy-fields { grid-template-columns: 1fr 1fr 1.1fr 1.8fr; }
  .compact-copy-fields.without-material { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .compact-process { grid-column: 2 / -1; justify-self: end; margin: 0; }
  .compact-process-options { flex-wrap: wrap; }
}
@media (max-width: 700px) {
  .compact-quote-layout { padding: 17px 12px 24px; }
  .compact-quote-heading h1 { font-size: 22px; }
  .compact-order-info { padding: 12px; }
  .compact-order-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .compact-service-toolbar { gap: 6px 15px; }
  .compact-service-label { width: 100%; }
  .compact-service-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compact-copy { grid-template-columns: 48px minmax(0, 1fr); gap: 12px; margin-bottom: 14px; }
  .compact-product { width: 150px; max-width: 100%; }
  .compact-copy-fields, .compact-copy-fields.without-material { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 12px; }
  .compact-copy-fields.without-material > .field:last-child { grid-column: 1 / -1; }
  .compact-copy-fields .field input, .compact-copy-fields .field select { height: 36px; }
  .compact-quote-input > span { top: 10px; }
  .compact-process { grid-column: 1 / -1; justify-self: start; }
  .compact-process-options { justify-content: flex-start; gap: 5px 15px; }
  .compact-copies-heading { min-height: 47px; }
  .compact-text-button { font-size: 11px; }
  .compact-add-copy { min-height: 40px; }
}
@media print {
  .topbar,
  .product-sidebar,
  .quote-editor,
  .summary-actions,
  .toast {
    display: none !important;
  }

  .app-shell,
  .quote-layout {
    display: block;
  }

  .quote-summary {
    position: static;
    max-height: none;
    margin: 0;
    border: 0;
    box-shadow: none;
  }
}
/* Supplier inquiry inherits the compact quotation controls. */
.supplier-summary { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.supplier-summary > button { width: 100%; justify-content: center; }
.supplier-summary p, .supplier-help, .supplier-current p { color: var(--muted); font-size: 12px; line-height: 1.7; }
.supplier-dialog { width: min(820px, calc(100vw - 32px)); }
.supplier-dialog form { display: grid; gap: 12px; }
.supplier-links { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.supplier-links a { color: var(--primary); }
.supplier-current { padding-block: 12px; border-block: 1px solid var(--line); }
.supplier-current summary { cursor: pointer; font-weight: 600; }
.supplier-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.supplier-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; min-width: 0; }
.supplier-field input, .supplier-field textarea { width: 100%; min-width: 0; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); }
.supplier-dialog .supplier-field textarea { height: 96px; min-height: 80px; resize: vertical; }
.supplier-costs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.supplier-check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.6; }
.supplier-check input { flex: 0 0 auto; width: 16px; height: 16px; margin-top: 3px; }
.supplier-result { padding: 12px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 4px; white-space: pre-line; line-height: 1.8; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .supplier-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .supplier-costs { grid-template-columns: 1fr; }
  .supplier-dialog .record-dialog-actions { flex-wrap: wrap; }
  .supplier-dialog input, .supplier-dialog button { min-height: 40px; }
}

/* Store finance pages share the order ledger and its compact controls. */
.finance-shop-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.finance-shop-tabs .is-active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); font-weight: 700; }
.order-search-bar select[name="platform"] { width: 168px; }
@media (min-width: 1201px) {
  .order-table th, .order-table td, .order-table td:nth-child(1), .order-table .order-product-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .order-table td { height: 52px; padding-block: 9px; }
  .order-table td > strong, .order-table .order-tracking-readonly { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .order-table .order-source-label, .order-table .order-fulfillment-status { display: none; }
  .order-table .order-actions { display: flex; flex-wrap: nowrap; gap: 4px; }
  .order-table .order-actions button { width: auto; flex: 1 1 auto; height: 30px; padding: 4px; white-space: nowrap; }
  .order-table .order-refund-button { flex-grow: 2; }
  .order-table .order-files-button { height: 32px; padding-block: 0; }
  .order-table .order-files-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .order-table .order-files-button svg, .order-table .editable-amount svg { display: none; }
  .order-table .editable-amount { height: 32px; min-height: 32px; }
}
@media (max-width: 600px) {
  .finance-shop-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .finance-shop-tabs button { min-width: 0; min-height: 44px; padding-inline: 6px; }
  .order-search-bar select[name="platform"] { width: 100%; }
}

@media (min-width: 1201px) and (max-width: 1600px) {
  .app-shell:has(.order-table) { grid-template-columns: 156px minmax(0, 1fr); }
  .app-shell:has(.order-table) .topbar { padding-inline: 10px; }
  .app-shell:has(.order-table) .brand { gap: 6px; margin-inline: 0; }
  .app-shell:has(.order-table) .brand-mark { width: 30px; height: 34px; flex-shrink: 0; }
  .app-shell:has(.order-table) .brand small { font-size: 8px; letter-spacing: 0; }
  .app-shell:has(.order-table) .nav-button { padding-inline: 10px; }
  .orders-view:has(.order-table) { padding-inline: 12px; }
  .order-table td:nth-child(1), .order-table td:nth-child(3), .order-table td:nth-child(4), .order-table td:nth-child(5) { font-size: 11px; }
  .order-table th:nth-child(1), .order-table td:nth-child(1) { width: 11.5%; }
  .order-table th:nth-child(2), .order-table td:nth-child(2) { width: 5.9%; }
  .order-table th:nth-child(3), .order-table td:nth-child(3) { width: 11%; }
  .order-table th:nth-child(4), .order-table td:nth-child(4) { width: 8.1%; }
  .order-table th:nth-child(5), .order-table td:nth-child(5) { width: 5.5%; }
  .order-table th:nth-child(6), .order-table td:nth-child(6) { width: 4.8%; }
  .order-table th:nth-child(7), .order-table td:nth-child(7) { width: 4.7%; }
  .order-table th:nth-child(8), .order-table td:nth-child(8) { width: 4.2%; }
  .order-table th:nth-child(9), .order-table td:nth-child(9) { width: 4.2%; }
  .order-table th:nth-child(10), .order-table td:nth-child(10) { width: 5.5%; }
  .order-table th:nth-child(11), .order-table td:nth-child(11) { width: 5.3%; }
  .order-table th:nth-child(12), .order-table td:nth-child(12) { width: 4%; }
  .order-table th:nth-child(13), .order-table td:nth-child(13) { width: 5.8%; }
  .order-table th:nth-child(14), .order-table td:nth-child(14) { width: 4.8%; }
  .order-table th:nth-child(15), .order-table td:nth-child(15) { width: 6.2%; }
  .order-table th:nth-child(16), .order-table td:nth-child(16) { width: 8.5%; }
}
