:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-soft: #f9fafc;
  --text: #202633;
  --muted: #6b7280;
  --line: #d9dee8;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green: #16a34a;
  --green-soft: #eaf8ef;
  --amber: #d97706;
  --amber-soft: #fff5df;
  --red: #dc2626;
  --red-soft: #fff0f0;
  --teal: #0f766e;
  --teal-soft: #e8f7f5;
  --violet: #7c3aed;
  --violet-soft: #f3edff;
  font-family:
    Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
}

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

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.suggest-input.has-value {
  border-color: #b9c7dd;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.combo-field {
  position: relative;
}

.combo-input {
  padding-right: 38px;
}

.combo-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: #f1f5f9;
  color: #475569;
  transform: translateY(-50%);
  box-shadow: none;
}

.combo-toggle:hover {
  transform: translateY(-50%);
  box-shadow: none;
  background: #e8eef8;
}

.combo-field.open .combo-toggle {
  background: #dbeafe;
  color: #1d4ed8;
}

.combo-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid #cfd9e8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16);
}

.combo-field.open .combo-menu {
  display: grid;
  gap: 4px;
}

.combo-option {
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.combo-option:hover {
  background: #eef4ff;
}

.combo-menu.is-empty::after {
  content: "没有匹配选项，可直接输入新名称";
  display: block;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
  opacity: 1;
}

select.placeholder-select {
  color: #94a3b8;
}

select option {
  color: var(--text);
}

select option[value=""] {
  color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #93b4ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
  outline: 0;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

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

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 20px 16px;
}

.sidebar-head {
  display: block;
}

.mobile-menu-toggle {
  display: none;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 4px 22px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

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

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

.nav {
  display: grid;
  gap: 10px;
}

.nav-group {
  display: grid;
  gap: 5px;
}

.nav-item,
.nav-subitem {
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  color: #374151;
  cursor: pointer;
}

.nav-item:hover,
.nav-subitem:hover {
  background: #f3f6fb;
}

.nav-item.active {
  background: var(--blue-soft);
  color: #1746b8;
  font-weight: 700;
}

.nav-parent {
  font-weight: 700;
}

.nav-subitems {
  display: grid;
  gap: 3px;
  padding-left: 12px;
}

.nav-subitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 8px 10px;
  color: #64748b;
  font-size: 13px;
}

.nav-subitem.active {
  background: #f1f5ff;
  color: #1746b8;
  font-weight: 700;
}

.nav-action {
  justify-content: flex-start;
  color: var(--blue);
  font-weight: 700;
}

.nav-count {
  min-width: 22px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #eef2f7;
  color: #475569;
  font-size: 12px;
  text-align: center;
}

.nav-subitem.active .nav-count {
  background: #dbe7ff;
  color: #1746b8;
}

.main {
  min-width: 0;
  padding: 22px 26px 36px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar > div:first-child {
  flex: 0 0 auto;
  min-width: 152px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 0;
}

h2 {
  line-height: 1.15;
  word-break: keep-all;
}

.top-actions {
  display: flex;
  flex: 1 1 720px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.search {
  display: flex;
  flex: 1 1 280px;
  align-items: center;
  gap: 8px;
  width: auto;
  min-width: 240px;
  max-width: 420px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
}

.top-select {
  flex: 0 1 132px;
  width: 132px;
  min-height: 40px;
  background: #fff;
}

.filter-select {
  flex-basis: 148px;
  width: 148px;
}

.period-select {
  flex-basis: 118px;
  width: 118px;
}

.period-value-select {
  flex-basis: 138px;
  width: 138px;
}

.primary-btn,
.secondary-btn,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.09);
}

.primary-btn {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
}

.secondary-btn {
  padding: 8px 11px;
}

.danger-btn {
  border-color: #fecaca;
  background: #fff7f7;
  color: var(--red);
}

.danger-btn:hover {
  border-color: #fca5a5;
  background: #fff0f0;
}

.field-button {
  width: 100%;
  margin: 8px 0 6px;
  text-align: center;
}

.icon-btn {
  width: 34px;
  height: 34px;
  font-size: 20px;
  line-height: 1;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

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

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 14px;
}

.analytics-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  margin-bottom: 16px;
}

.analytics-notes {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
  color: #475569;
  font-size: 13px;
  line-height: 1.55;
}

.analytics-notes p {
  margin: 0;
}

.analytics-table td,
.analytics-table th {
  font-size: 13px;
}

.analytics-pie-card {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 18% 15%, rgba(37, 99, 235, 0.08), transparent 30%),
    linear-gradient(145deg, #ffffff, #f8fbff);
}

.pie-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 190px;
}

.pie-stage::before {
  content: "";
  position: absolute;
  width: 150px;
  height: 22px;
  bottom: 13px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.13);
  filter: blur(14px);
}

.pie-chart {
  position: relative;
  display: grid;
  place-items: center;
  width: 170px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow:
    inset -12px -16px 28px rgba(15, 23, 42, 0.14),
    inset 8px 10px 20px rgba(255, 255, 255, 0.22),
    0 24px 40px rgba(15, 23, 42, 0.14);
  transform: rotate(-12deg);
}

.pie-chart::after {
  content: "";
  position: absolute;
  width: 82px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    linear-gradient(145deg, #ffffff, #eef3fb);
  box-shadow:
    inset 0 2px 8px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(15, 23, 42, 0.05);
}

.pie-chart span,
.pie-chart small {
  position: relative;
  z-index: 1;
}

.pie-chart span {
  font-size: 25px;
  font-weight: 800;
  color: #0f172a;
  transform: rotate(12deg);
}

.pie-chart small {
  display: block;
  margin-top: 28px;
  color: var(--muted);
  font-size: 11px;
  transform: rotate(12deg);
}

.pie-chart.empty {
  background: #e5e7eb;
}

.pie-legend {
  display: grid;
  gap: 10px;
}

.pie-legend-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e5eaf3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.pie-legend-row i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.pie-legend-row span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
}

.pie-legend-row strong {
  min-width: 46px;
  text-align: right;
  color: #0f172a;
  font-size: 18px;
}

.pie-legend-row em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.035);
  transition:
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.panel:hover {
  border-color: #cdd7e6;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.055);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  font-size: 16px;
}

.edit-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.panel-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-wrap {
  overflow: auto;
}

.order-table-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.date-stack {
  display: grid;
  gap: 3px;
  min-width: 132px;
  line-height: 1.35;
}

.date-stack span {
  display: flex;
  gap: 6px;
  justify-content: space-between;
  color: #334155;
  font-size: 12px;
}

.date-stack b {
  color: #64748b;
  font-weight: 700;
}

.date-simple {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 84px;
  white-space: nowrap;
}

.date-simple span {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  background: #eef2ff;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.date-simple strong {
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 13px;
}

.order-thumb {
  display: block;
  width: 52px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.order-thumb.placeholder {
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.image-upload-field {
  min-height: 152px;
}

.image-preview {
  display: none;
  width: 96px;
  height: 120px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 8px 0;
  background: #fff;
}

.image-preview.visible,
.image-preview[src] {
  display: block;
}

.style-image-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.style-image-gallery .empty-image-hint {
  margin: 0;
  color: #94a3b8;
  font-size: 12px;
}

.style-image-item {
  position: relative;
  width: 78px;
  height: 96px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.style-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.style-image-item button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  line-height: 1;
  cursor: pointer;
}

.paste-zone {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px dashed #93b4ff;
  border-radius: 8px;
  background: #f8fbff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  margin-top: 8px;
  padding: 8px;
  cursor: text;
}

.paste-zone:focus {
  outline: 2px solid #93b4ff;
  outline-offset: 2px;
}

th {
  color: #4b5563;
  background: #fbfcfe;
  font-weight: 700;
}

.order-table {
  table-layout: fixed;
  min-width: 1360px;
}

.order-table th,
.order-table td {
  padding: 7px 8px;
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
  vertical-align: middle;
}

.order-table th:nth-child(1),
.order-table td:nth-child(1) {
  width: 104px;
}

.order-table th:nth-child(2),
.order-table td:nth-child(2) {
  width: 94px;
}

.order-table th:nth-child(3),
.order-table td:nth-child(3) {
  width: 64px;
}

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

.order-table th:nth-child(5),
.order-table td:nth-child(5) {
  width: 104px;
}

.order-table th:nth-child(6),
.order-table td:nth-child(6) {
  width: 118px;
}

.order-table th:nth-child(7),
.order-table td:nth-child(7) {
  width: 96px;
}

.order-table th:nth-child(8),
.order-table td:nth-child(8) {
  width: 102px;
}

.order-table th:nth-child(9),
.order-table td:nth-child(9) {
  width: 112px;
}

.order-table th:nth-child(10),
.order-table td:nth-child(10) {
  width: 84px;
}

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

.order-table th:nth-child(12),
.order-table td:nth-child(12) {
  width: 84px;
}

.order-table th:nth-child(13),
.order-table td:nth-child(13) {
  width: 104px;
}

.order-table th:nth-child(14),
.order-table td:nth-child(14) {
  width: 126px;
}

.order-table .tag {
  white-space: nowrap;
  overflow-wrap: normal;
}

.order-table .order-thumb {
  width: 34px;
  height: 42px;
  border-radius: 7px;
}

.money-stack {
  display: grid;
  gap: 6px;
  min-width: 126px;
  line-height: 1.2;
}

.money-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 8px;
  padding: 6px 8px;
  background: #f8fafc;
  border: 1px solid #e5eaf2;
}

.money-main b {
  color: #64748b;
  font-size: 11px;
}

.money-main strong {
  color: #0f172a;
  font-size: 13px;
}

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

.money-grid span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #334155;
  font-size: 11px;
}

.money-grid b {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 700;
  font-size: 10px;
}

.money-grid .profit-ready {
  color: var(--green);
  font-weight: 800;
}

.next-cell {
  max-width: 120px;
  white-space: normal;
  line-height: 1.45;
}

.cell-link {
  border: 0;
  background: transparent;
  color: #1d4ed8;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.cell-link:hover {
  text-decoration: underline;
}

.next-cell-link {
  display: -webkit-box;
  max-width: 150px;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  color: #334155;
  font-weight: 700;
}

.stage-stack {
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.order-table .stage-stack .tag {
  width: auto;
  min-width: 86px;
  justify-content: center;
  padding: 4px 6px;
  text-align: center;
  line-height: 1.2;
  word-break: keep-all;
}

.order-table tr.order-overdue > td,
.order-table tr.order-delay-soon > td {
  background: #fff1f2;
}

.order-table tr.order-overdue:hover > td,
.order-table tr.order-delay-soon:hover > td {
  background: #ffe4e6;
}

.order-id-cell[data-delay-label] {
  position: relative;
  padding-top: 24px;
}

.order-id-cell[data-delay-label]::before {
  content: attr(data-delay-label);
  position: absolute;
  top: 5px;
  left: 7px;
  display: inline-flex;
  align-items: center;
  max-width: calc(100% - 14px);
  border: 1px solid #fecaca;
  border-radius: 999px;
  padding: 2px 7px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.table-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

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

.mini-btn {
  border: 1px solid #d9e7ff;
  border-radius: 999px;
  padding: 5px 8px;
  background: #eef5ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mini-btn:hover {
  background: #dfeaff;
}

.danger-mini {
  border-color: #fee2e2;
  background: #fff7f7;
  color: var(--red);
}

.danger-mini:hover {
  background: #fff0f0;
  border-color: #fecaca;
}

.toast-message {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  transform: translateY(12px);
  opacity: 0;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 11px 15px;
  background: #ffffff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

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

.order-create-page {
  max-width: 1380px;
}

body.create-mode .top-actions {
  display: none;
}

.order-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.edit-order-form,
.aftersale-form {
  padding: 0;
}

.edit-form-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid #dbe4f2;
  border-radius: 8px;
  background: #fff;
}

.edit-form-toolbar strong {
  display: block;
  color: #0f172a;
}

.edit-form-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.order-create-page .detail-grid {
  padding: 0;
  margin-bottom: 0;
}

.form-section {
  border: 1px solid #dbe4f2;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.04);
  padding: 14px;
}

.form-section-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2f8;
}

.form-section-heading h4 {
  margin: 0;
  color: #0f172a;
  font-size: 15px;
}

.form-section-heading p {
  max-width: 820px;
  margin: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.55;
  text-align: right;
}

.form-section-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.form-section-wide {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.form-section-wide > .full-section,
.form-section-wide > .work-order-section,
.form-section-wide > .full-field {
  margin-bottom: 10px;
}

.custom-measurement-wrapper[hidden],
.size-chart-preview[hidden] {
  display: none;
}

.size-chart-preview {
  background: #f8fbff;
}

.size-preview-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.size-preview-title strong {
  margin: 0;
  color: #1d4ed8;
}

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

.size-preview-grid span {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid #dbe4f2;
  border-radius: 8px;
  background: #fff;
}

.size-preview-grid b {
  color: #64748b;
  font-size: 11px;
}

.size-preview-grid em {
  color: #0f172a;
  font-style: normal;
  font-weight: 800;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 2px 0 4px;
}

.edit-order-actions {
  justify-content: space-between;
  align-items: center;
}

.form-footer-left,
.form-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.form-footer-right {
  justify-content: flex-end;
}

.order-create-page .form-footer {
  position: sticky;
  right: 0;
  bottom: 14px;
  z-index: 60;
  padding: 12px;
  border: 1px solid #dbe4f2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(10px);
}

.order-form .form-footer,
.edit-order-form .form-footer,
.aftersale-form .form-footer,
.product-detail-form .form-footer,
.quick-edit-form .form-footer,
.floating-form-footer {
  position: sticky;
  bottom: 0;
  z-index: 60;
  padding: 12px;
  border: 1px solid #dbe4f2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 -12px 34px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(10px);
}

.order-create-page {
  padding-bottom: 84px;
}

.required-dot {
  margin-left: 4px;
  color: #dc2626;
  font-size: 12px;
  font-weight: 900;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover {
  background: #f8fbff;
}

.clickable-card,
.clickable-step {
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.clickable-card:hover,
.clickable-step:hover {
  border-color: #93b4ff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.blue {
  background: var(--blue-soft);
  color: #1d4ed8;
}

.tag.green {
  background: var(--green-soft);
  color: var(--green);
}

.tag.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.red {
  background: var(--red-soft);
  color: var(--red);
}

.tag.teal {
  background: var(--teal-soft);
  color: var(--teal);
}

.tag.violet {
  background: var(--violet-soft);
  color: var(--violet);
}

.workflow {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.step {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid #edf0f5;
  border-radius: 8px;
  background: var(--panel-soft);
}

.step-num {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: #e5e7eb;
  font-weight: 800;
  font-size: 12px;
}

.step h4 {
  margin: 0 0 4px;
  font-size: 13px;
}

.step p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.directory-cards {
  padding: 14px;
}

.info-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  position: relative;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.info-card:hover {
  transform: translateY(-2px);
  border-color: #b9c8df;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.08);
}

.directory-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.info-card h3 {
  margin: 0;
  color: #0f172a;
  font-size: 18px;
  line-height: 1.25;
}

.directory-card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.product-table-wrap {
  overflow-x: auto;
}

.product-table {
  min-width: 1280px;
  table-layout: fixed;
}

.product-col-image {
  width: 78px;
}

.product-col-sku {
  width: 108px;
}

.product-col-name {
  width: 250px;
}

.product-col-category {
  width: 190px;
}

.product-col-attributes,
.product-col-materials {
  width: 210px;
}

.product-col-price {
  width: 90px;
}

.product-col-actions {
  width: 110px;
}

.product-table th,
.product-table td {
  overflow: hidden;
  vertical-align: top;
}

.product-table th:nth-child(1),
.product-table td:nth-child(1) {
  width: 78px;
}

.product-table th:nth-child(2),
.product-table td:nth-child(2) {
  width: 108px;
}

.product-table th:nth-child(3),
.product-table td:nth-child(3) {
  width: 250px;
}

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

.product-table th:nth-child(5),
.product-table td:nth-child(5) {
  width: 210px;
}

.product-table th:nth-child(6),
.product-table td:nth-child(6) {
  width: 210px;
}

.product-table th:nth-child(7),
.product-table td:nth-child(7) {
  width: 90px;
}

.product-table th:nth-child(8),
.product-table td:nth-child(8) {
  width: 110px;
}

.product-thumb {
  width: 56px;
  height: 72px;
}

.product-name-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-width: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.product-name-cell span,
.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.product-category-stack {
  min-width: 0;
}

.product-category-stack span {
  justify-content: flex-start;
  white-space: normal;
}

.product-attribute-list,
.product-material-mini {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-width: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.product-attribute-list span,
.product-material-mini span {
  color: #334155;
  font-size: 12px;
  line-height: 1.35;
}

.product-attribute-list b {
  display: inline-block;
  min-width: 34px;
  margin-right: 6px;
  color: #64748b;
}

.product-lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.product-lookup-btn {
  min-height: 42px;
  padding: 0 12px;
  white-space: nowrap;
}

.product-match-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
}

.product-match-hint.matched {
  color: var(--teal);
}

.product-summary {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 4px 0 18px;
}

.product-summary-media img,
.product-summary-media .order-thumb {
  width: 132px;
  height: 168px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.product-summary-main {
  display: grid;
  gap: 10px;
}

.product-summary-title {
  display: grid;
  gap: 4px;
}

.product-summary-title strong {
  color: #0f172a;
  font-size: 20px;
}

.product-summary-title span {
  color: #334155;
  font-size: 15px;
}

.product-summary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.product-summary-main p {
  margin: 0;
  color: #475569;
  line-height: 1.55;
}

.product-image-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.product-image-strip img {
  width: 92px;
  height: 118px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-attribute-panel .product-attribute-list {
  max-width: none;
}

.product-material-table-wrap {
  grid-column: 1 / -1;
  overflow-x: auto;
  padding-bottom: 4px;
}

.product-material-table {
  min-width: 1180px;
  table-layout: fixed;
}

.product-material-table th:nth-child(1),
.product-material-table td:nth-child(1) {
  width: 130px;
}

.product-material-table th:nth-child(2),
.product-material-table td:nth-child(2) {
  width: 160px;
}

.product-material-table th:nth-child(3),
.product-material-table td:nth-child(3) {
  width: 200px;
}

.product-material-table th:nth-child(4),
.product-material-table td:nth-child(4) {
  width: 170px;
}

.product-material-table th:nth-child(5),
.product-material-table td:nth-child(5) {
  width: 120px;
}

.product-material-table th:nth-child(6),
.product-material-table td:nth-child(6) {
  width: 88px;
}

.product-material-table th:nth-child(7),
.product-material-table td:nth-child(7) {
  width: 312px;
}

.product-material-table th,
.product-material-table td {
  padding: 8px;
}

.product-material-table input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid #edf0f5;
  color: var(--muted);
  font-size: 13px;
}

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

.card-action {
  margin-top: 12px;
}

.card-detail-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  border: 1px solid #d9e7ff;
  border-radius: 999px;
  padding: 7px 10px;
  background: #eef5ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.card-detail-btn:hover {
  background: #dfeaff;
}

.card-detail-btn.teal-btn {
  border-color: #c8f0eb;
  background: #e8f7f5;
  color: #0f766e;
}

.card-detail-btn.teal-btn .btn-icon {
  color: #0f766e;
}

.card-detail-btn.teal-btn:hover {
  background: #d9f1ed;
}

.btn-icon {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: #1d4ed8;
  font-size: 16px;
  line-height: 1;
}

.quiet-danger-btn {
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 9px;
  background: transparent;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  opacity: 0.72;
  cursor: pointer;
}

.quiet-danger-btn:hover {
  background: #fff0f0;
  border-color: #fecaca;
  opacity: 1;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

.empty-state p {
  margin: 0 auto 14px;
  max-width: 420px;
}

dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  animation: dialog-in 0.18s ease-out;
}

dialog.fullscreen-dialog {
  width: calc(100vw - 22px);
  max-width: none;
  height: calc(100vh - 22px);
  max-height: none;
}

dialog.wide-dialog {
  width: min(1280px, calc(100vw - 28px));
  max-width: none;
  height: min(86vh, calc(100vh - 28px));
  max-height: none;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.34);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dialog-card {
  background: #fff;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

#dialog-body {
  padding: 18px;
  overflow: auto;
}

dialog.fullscreen-dialog #dialog-body {
  height: calc(100vh - 104px);
}

dialog.wide-dialog #dialog-body {
  max-height: calc(86vh - 88px);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.detail-item {
  min-width: 0;
  background: #f8fafc;
  border: 1px solid #edf0f5;
  border-radius: 8px;
  padding: 10px;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.detail-item:focus-within {
  background: #fff;
  border-color: #c8d7f4;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.06);
}

.detail-item.field-error {
  background: #fff7f7;
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.detail-item.field-error > span::after {
  content: " 必填";
  color: #dc2626;
  font-weight: 800;
}

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

.detail-item strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  word-break: break-word;
}

.detail-item small {
  display: block;
  margin-top: 6px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.45;
}

.compact-panel {
  margin-bottom: 16px;
}

.compact-panel .detail-grid {
  padding: 14px;
  margin-bottom: 0;
}

.compact-panel .primary-btn {
  margin: 0 14px 14px;
}

.supplier-summary-grid .detail-item strong {
  font-size: 18px;
}

.supplier-edit-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.shipping-date-item {
  grid-column: 1 / -1;
}

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

.shipping-date-grid small,
.final-cost-field small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.final-cost-field small {
  margin: 6px 0 0;
}

.locked-field {
  opacity: 0.72;
}

.locked-field input {
  background: #eef2f7;
  color: #94a3b8;
  cursor: not-allowed;
}

.locked-field select,
.locked-field textarea,
.locked-field .combo-input {
  background: #eef2f7;
  color: #94a3b8;
  cursor: not-allowed;
}

.disabled-zone {
  background: #eef2f7;
  color: #94a3b8;
  cursor: not-allowed;
}

.required-inline small::after {
  content: " · 必填";
  color: #dc2626;
  font-weight: 800;
}

.readonly-image-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
  align-items: center;
}

.readonly-image-gallery img {
  width: 70px;
  height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  cursor: zoom-in;
}

.date-stack,
.compact-money {
  display: grid;
  gap: 4px;
  color: #334155;
  font-size: 12px;
  line-height: 1.35;
}

.finance-summary small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.finance-summary strong {
  font-size: 17px;
}

.profit-positive {
  color: #16a34a;
}

.profit-negative {
  color: #ef4444;
}

.measurement-guide {
  cursor: zoom-in;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.72);
}

dialog.image-lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 28px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

dialog.image-lightbox::backdrop {
  background: rgba(15, 23, 42, 0.72);
}

.image-lightbox img {
  max-width: min(96vw, 1280px);
  max-height: 92vh;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.34);
}

.image-lightbox-close {
  position: fixed;
  right: 22px;
  top: 18px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 24px;
  line-height: 1;
}

.full-field {
  grid-column: 1 / -1;
  display: block;
  margin-bottom: 12px;
}

.full-section {
  grid-column: 1 / -1;
}

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

.section-heading b {
  color: #1d4ed8;
}

.section-heading strong {
  margin: 0;
  color: #1d4ed8;
  font-size: 12px;
}

.measurement-heading-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.unit-toggle {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.unit-toggle button {
  min-width: 58px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: #64748b;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.unit-toggle button:last-child {
  border-right: 0;
}

.unit-toggle button.active {
  background: #111827;
  color: #fff;
}

.guide-toggle {
  margin-bottom: 12px;
}

.guide-toggle summary {
  color: #1d4ed8;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.measurement-guide {
  display: block;
  width: min(520px, 100%);
  max-height: 360px;
  object-fit: contain;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.measurement-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.measure-field span,
.plain-field span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.measure-field.required-measure span {
  color: #dc2626;
  font-weight: 800;
}

.plain-field {
  display: block;
}

.work-order-section {
  background: #fff;
}

body.work-order-fullscreen-active {
  overflow: hidden;
}

.work-order-section.fullscreen-work-order {
  position: fixed;
  inset: 18px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  padding: 18px;
  border: 1px solid #cfd9e8;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
}

.work-order-section.fullscreen-work-order .work-order-canvas {
  flex: 1;
  height: auto;
  min-height: 0;
  resize: none;
}

.work-order-section.fullscreen-work-order .order-notes {
  display: none;
}

.work-order-section.locked-work-order {
  border-color: #e2e8f0;
  background: #f8fafc;
}

.locked-work-order .work-order-canvas {
  background: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}

.locked-work-order .work-order-format-toolbar {
  opacity: 0.55;
  pointer-events: none;
}

.locked-work-order .work-order-header::after {
  content: "排期后工单已锁定";
  margin-left: auto;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef2ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}

.work-order-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.work-order-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.work-order-header strong {
  margin: 3px 0 0;
  color: #1d4ed8;
  font-size: 12px;
}

.work-order-format-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid #edf0f5;
  border-radius: 8px;
  background: #f8fafc;
}

.toolbar-group {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 3px;
  border: 1px solid #e5eaf3;
  border-radius: 9px;
  background: #fff;
}

.work-order-format-toolbar button,
.work-order-format-toolbar select,
.color-tool {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  font-size: 12px;
}

.work-order-format-toolbar button {
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 700;
}

.work-order-format-toolbar button:hover,
.work-order-format-toolbar button.active {
  border-color: #93b4ff;
  background: #eef4ff;
  color: #1d4ed8;
}

.format-icon {
  min-width: 32px;
  font-size: 13px;
}

.color-swatch-group {
  gap: 5px;
}

.color-swatch {
  min-width: 30px;
  padding: 4px;
}

.color-swatch span {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.14);
}

.work-order-format-toolbar select {
  width: auto;
  padding: 6px 28px 6px 10px;
}

.color-tool {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 4px 8px;
}

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

.color-tool input {
  width: 28px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
}

.work-order-canvas {
  height: 420px;
  min-height: 360px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  line-height: 1.6;
  outline: 0;
  overflow: auto;
  resize: vertical;
  white-space: normal;
}

.work-order-canvas:focus {
  border-color: #93b4ff;
  box-shadow: 0 0 0 3px rgba(147, 180, 255, 0.25);
}

.work-order-canvas:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
}

.work-order-canvas h4 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 800;
}

.work-order-canvas p {
  margin: 0 0 8px;
}

.work-order-image-frame {
  position: relative;
  display: inline-block;
  width: 360px;
  min-width: 160px;
  max-width: 100%;
  margin: 12px 10px 12px 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  vertical-align: top;
}

.work-order-image-frame.image-float-right {
  float: right;
  margin: 12px 0 12px 12px;
}

.work-order-image-frame.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.work-order-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.work-order-image-frame.image-missing {
  border-style: dashed;
  background: #fff7ed;
}

.work-order-image-frame.image-missing .work-order-image {
  display: none;
}

.work-order-image-missing,
.paste-image-warning {
  border: 1px dashed #fb923c;
  border-radius: 8px;
  background: #fff7ed;
  color: #c2410c;
  padding: 12px;
  font-size: 12px;
  font-weight: 700;
}

.work-order-image-tools {
  display: none;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}

.work-order-image-frame:hover .work-order-image-tools,
.work-order-image-frame.selected .work-order-image-tools {
  display: flex;
}

.work-order-image-tools button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #1f2937;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 12px;
}

.image-size-control {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #4b5563;
  font-size: 12px;
}

.image-size-control input {
  width: 120px;
  accent-color: #2563eb;
}

.image-size-control em {
  min-width: 44px;
  color: #1d4ed8;
  font-style: normal;
  font-weight: 700;
}

.order-notes {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #edf0f5;
}

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

.order-notes-title span {
  font-weight: 800;
}

.order-notes-title small,
.empty-note {
  color: var(--muted);
  font-size: 12px;
}

.note-composer {
  display: grid;
  gap: 8px;
}

.quick-edit-form .order-notes {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.quick-edit-form .note-composer textarea {
  width: 100%;
  min-height: 96px;
}

.note-image-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto 110px auto;
  gap: 8px;
  align-items: center;
}

.quick-edit-form .note-image-row {
  grid-template-columns: minmax(260px, 1.2fr) auto minmax(180px, 1fr) auto;
  align-items: stretch;
}

.note-paste-zone {
  margin: 0;
}

.notes-timeline {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.note-item {
  padding: 10px;
  border: 1px solid #edf0f5;
  border-radius: 8px;
  background: #fbfcff;
}

.note-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.note-item time {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.note-delete-btn {
  flex: 0 0 auto;
  padding: 3px 8px;
}

.note-item p {
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.note-item img {
  display: inline-block;
  width: 104px;
  height: 104px;
  margin-top: 8px;
  margin-right: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  cursor: zoom-in;
}

.note-image-gallery {
  min-width: 120px;
  margin-top: 0;
}

.note-image-gallery .style-image-item {
  width: 54px;
  height: 54px;
}

.copy-inline-btn {
  min-height: 30px;
  padding: 5px 10px;
  white-space: nowrap;
}

.edit-panel {
  margin-bottom: 16px;
  padding: 14px;
}

.export-result {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.export-result strong {
  display: block;
  margin-bottom: 8px;
  color: #1d4ed8;
}

.export-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.export-links a {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  background: #fff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.edit-grid {
  margin-bottom: 10px;
}

.system-panel {
  margin-top: 14px;
}

.stage-grid {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
}

.stage-grid .step {
  min-height: 116px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

@media (min-width: 1181px) and (max-width: 1320px) {
  .top-actions {
    gap: 8px;
  }

  .search {
    flex-basis: 180px;
    min-width: 180px;
    max-width: 240px;
    padding: 8px 10px;
  }

  .top-select {
    flex-basis: 106px;
    width: 106px;
  }

  .filter-select {
    flex-basis: 116px;
    width: 116px;
  }

  .period-select {
    flex-basis: 104px;
    width: 104px;
  }

  .period-value-select {
    flex-basis: 118px;
    width: 118px;
  }

  .top-actions .secondary-btn,
  .top-actions .primary-btn {
    padding-inline: 11px;
  }
}

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

  .sidebar {
    padding: 18px 12px;
  }

  .main {
    padding: 20px 18px 32px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar > div:first-child {
    min-width: 0;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .search {
    max-width: none;
  }

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

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

  .app-shell {
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  .nav {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .nav-group {
    flex: 0 0 min(190px, 44vw);
    min-width: 0;
  }

  .nav-subitems {
    padding-left: 0;
  }

  .nav-item,
  .nav-subitem {
    white-space: nowrap;
  }

  .topbar,
  .top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search {
    width: 100%;
  }

  .kpis,
  .workspace-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-section-heading {
    display: grid;
  }

  .form-section-heading p {
    text-align: left;
  }

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

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

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

  .shipping-date-item {
    grid-column: auto;
  }

  .shipping-date-grid {
    grid-template-columns: 1fr;
  }

  .product-summary {
    grid-template-columns: 1fr;
  }

  .product-summary-media img,
  .product-summary-media .order-thumb {
    width: 120px;
    height: 152px;
  }

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

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

@media (max-width: 820px) {
  body {
    background: #f8fafc;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    top: 0;
    z-index: 120;
    padding: 8px 10px;
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
  }

  .sidebar-head {
    display: flex;
    align-items: center;
    gap: 9px;
  }

  .mobile-menu-toggle {
    display: grid;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid #dbe4f2;
    border-radius: 8px;
    background: #fff;
    color: #1f2937;
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
  }

  body.mobile-nav-open .mobile-menu-toggle {
    border-color: #bcd0ff;
    background: var(--blue-soft);
    color: #1746b8;
  }

  .brand {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    gap: 9px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    font-size: 12px;
  }

  .brand h1 {
    font-size: 14px;
    line-height: 1.2;
  }

  .brand p {
    margin-top: 1px;
    font-size: 11px;
  }

  .nav {
    position: absolute;
    top: 52px;
    left: 10px;
    right: 10px;
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    max-height: min(68vh, 520px);
    overflow: auto;
    padding: 10px;
    border: 1px solid #dbe4f2;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
  }

  body.mobile-nav-open .nav {
    display: flex;
  }

  body.mobile-nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(15, 23, 42, 0.08);
    pointer-events: none;
  }

  body.mobile-nav-open .sidebar {
    z-index: 130;
    overflow: visible;
  }

  .nav-group {
    display: contents;
    min-width: 0;
  }

  .nav > .nav-item,
  .nav-group > .nav-parent {
    order: 1;
    flex: 0 0 auto;
    min-height: 34px;
    border: 1px solid #dbe4f2;
    border-radius: 999px;
    padding: 7px 11px;
    background: #fff;
    color: #334155;
    line-height: 1.2;
    white-space: nowrap;
  }

  .nav > .nav-item.active,
  .nav-group > .nav-parent.active {
    border-color: #bcd0ff;
    background: var(--blue-soft);
    color: #1746b8;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.08);
  }

  .nav-subitems {
    order: 2;
    display: none;
    flex: 0 0 100%;
    gap: 6px;
    padding: 2px 0 0;
    overflow-x: auto;
  }

  .nav-group.active-group .nav-subitems {
    display: flex;
  }

  .nav-subitem {
    flex: 0 0 auto;
    min-height: 32px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 6px 10px;
    background: #fff;
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
  }

  .nav-subitem.active {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
  }

  .nav-action {
    color: #2563eb;
  }

  .nav-count {
    min-width: 18px;
    padding: 1px 6px;
    font-size: 11px;
  }

  .main {
    padding: 12px 8px 74px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 12px;
  }

  h2 {
    font-size: 24px;
  }

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

  .search {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
  }

  .top-select,
  .filter-select,
  .period-select,
  .period-value-select,
  .top-actions .primary-btn,
  .top-actions .secondary-btn {
    width: 100%;
    min-width: 0;
  }

  #login-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 135;
    width: auto;
    max-width: 92px;
    min-height: 32px;
    padding: 6px 9px;
    overflow: hidden;
    background: #fff;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  .kpi {
    min-height: 74px;
    padding: 9px 10px;
  }

  .kpi strong {
    margin-top: 4px;
    font-size: 18px;
    line-height: 1.18;
  }

  .kpi span {
    font-size: 11px;
  }

  .panel {
    border-radius: 8px;
  }

  .panel-header {
    display: grid;
    gap: 8px;
  }

  .order-table-wrap,
  .product-table-wrap {
    overflow-x: visible;
  }

  .analytics-grid,
  .analytics-pie-card {
    grid-template-columns: 1fr;
  }

  .analytics-table {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .analytics-table thead {
    display: none;
  }

  .analytics-table tbody {
    display: grid;
    gap: 10px;
  }

  .analytics-table tr {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }

  .analytics-table td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #eef2f7;
    font-size: 12px;
  }

  .analytics-table td:last-child {
    border-bottom: 0;
  }

  .analytics-table td[data-label]::before {
    content: attr(data-label);
    color: #64748b;
    font-weight: 700;
  }

  .order-table,
  .product-table {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .order-table colgroup,
  .product-table colgroup,
  .order-table thead,
  .product-table thead {
    display: none;
  }

  .order-table tbody,
  .product-table tbody {
    display: grid;
    gap: 10px;
  }

  .order-table tr,
  .product-table tr {
    display: grid;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }

  .order-table tr.order-overdue,
  .order-table tr.order-delay-soon {
    background: #fff1f2;
  }

  .order-table tr.order-overdue > td,
  .order-table tr.order-delay-soon > td {
    background: transparent;
  }

  .order-table td,
  .product-table td {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    width: 100% !important;
    padding: 8px 10px;
    border-bottom: 1px solid #eef2f7;
    font-size: 12px;
  }

  .order-table td:last-child,
  .product-table td:last-child {
    border-bottom: 0;
  }

  .order-table td[data-label]::before,
  .product-table td[data-label]::before {
    content: attr(data-label);
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
  }

  .order-id-cell[data-delay-label] {
    padding-top: 10px;
  }

  .order-id-cell[data-delay-label]::before {
    content: attr(data-label);
    position: static;
    display: block;
    max-width: none;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
  }

  .order-id-cell[data-delay-label]::after {
    content: attr(data-delay-label);
    display: inline-flex;
    width: fit-content;
    margin-top: 6px;
    border: 1px solid #fecaca;
    border-radius: 999px;
    padding: 2px 7px;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
  }

  .table-actions {
    width: 100%;
  }

  .order-table tr[data-order] td[data-label="供应商"],
  .order-table tr[data-order] td[data-label="创建时间"],
  .order-table tr[data-order] td[data-label="付款"],
  .order-table tr[data-order] td[data-label="付款方式"],
  .order-table tr[data-order] td[data-label="订单金额"],
  .order-table tr[data-order] td[data-label="下一步"] {
    display: none;
  }

  .order-table tr[data-order] [data-edit-notes],
  .order-table tr[data-order] [data-delete-order] {
    display: none;
  }

  .order-table tr[data-order] .table-actions {
    justify-content: flex-start;
  }

  .mini-btn {
    min-height: 28px;
    padding: 4px 9px;
    font-size: 12px;
  }

  .detail-grid,
  .form-section-grid,
  .shipping-date-grid,
  .measurement-grid,
  .size-preview-grid {
    grid-template-columns: 1fr;
  }

  .form-section {
    padding: 12px;
  }

  .dialog-header,
  .form-footer-left,
  .form-footer-right {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .form-footer,
  .edit-order-actions,
  .form-footer-left,
  .form-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .order-form .form-footer,
  .edit-order-form .form-footer,
  .aftersale-form .form-footer,
  .product-detail-form .form-footer,
  .quick-edit-form .form-footer,
  .floating-form-footer {
    overflow-x: auto;
    padding: 8px;
  }

  .form-footer button {
    flex: 1 1 calc(50% - 8px);
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .form-footer .primary-btn {
    flex-basis: 100%;
    min-width: 108px;
  }

  .form-footer .danger-btn {
    min-width: 86px;
  }

  dialog,
  dialog.wide-dialog,
  dialog.fullscreen-dialog {
    width: calc(100vw - 12px);
    height: auto;
    max-height: calc(100vh - 12px);
  }

  #dialog-body {
    padding: 12px;
  }
}

.login-panel {
  max-width: 560px;
  margin: 80px auto;
}

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

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 13px;
}

.login-hint {
  margin: 0;
  color: #64748b;
  font-size: 12px;
}
