:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --text: #18202f;
  --muted: #687386;
  --line: #dfe5ee;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #c9372c;
  --warn: #b7791f;
  --ok: #218838;
  --soft-blue: #eaf2ff;
  --soft-green: #eaf8ef;
  --soft-red: #fff0ef;
  --soft-yellow: #fff7e6;
  --shadow: 0 12px 28px rgba(20, 30, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #eef2f7;
  color: var(--text);
}

button.secondary:hover {
  background: #dde5f0;
}

button.danger {
  background: var(--danger);
}

button.link {
  background: transparent;
  color: var(--primary);
  padding: 0 6px;
  min-height: 32px;
}

button.link.danger {
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1.5px solid #b9c4d3;
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #b9d5ff;
  border-color: var(--primary);
}

.pretty-date-input {
  cursor: pointer;
  background:
    linear-gradient(45deg, transparent 50%, #64748b 50%) calc(100% - 17px) 17px / 6px 6px no-repeat,
    linear-gradient(135deg, #64748b 50%, transparent 50%) calc(100% - 11px) 17px / 6px 6px no-repeat,
    #fff;
  padding-right: 34px;
}

.pretty-date-popover {
  position: fixed;
  z-index: 20000;
  border: 1px solid #cfd8e6;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.24);
}

.pretty-date-head,
.pretty-date-foot {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
  align-items: center;
}

.pretty-date-head strong {
  text-align: center;
  font-size: 15px;
}

.pretty-date-head button,
.pretty-date-foot button {
  min-height: 34px;
  border-radius: 6px;
  padding: 0 10px;
}

.pretty-date-foot {
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.pretty-date-weekdays,
.pretty-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.pretty-date-weekdays {
  margin: 12px 0 6px;
}

.pretty-date-weekdays span {
  color: #64748b;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.pretty-date-day,
.pretty-date-month,
.pretty-date-year {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0;
  background: #f8fafc;
  color: #1f2937;
  font-size: 13px;
}

.pretty-date-day:hover,
.pretty-date-month:hover,
.pretty-date-year:hover {
  border-color: #9ec5ff;
  background: #eef6ff;
}

.pretty-date-day.outside {
  color: #a1adbd;
  background: #fbfdff;
}

.pretty-date-day.today {
  border-color: #22a06b;
  color: #176b48;
  font-weight: 800;
}

.pretty-date-day.selected,
.pretty-date-month.selected,
.pretty-date-year.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.pretty-month-grid,
.pretty-year-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 6px;
  color: #3f4b5f;
  font-size: 13px;
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: #eef2f6;
}

.login-box {
  width: 100%;
  min-height: 100vh;
  background: var(--panel);
  box-shadow: none;
  border: 0;
  border-radius: 0;
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}

.login-identity {
  min-height: 100vh;
  padding: 46px 34px;
  background: #f8fafc;
  color: #1e293b;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid #d8e0ea;
}

.login-brand-image {
  width: min(100%, 300px);
  height: auto;
  display: block;
  margin-bottom: 26px;
}

.login-identity strong {
  font-size: 24px;
  line-height: 1.25;
}

.login-identity span {
  margin-top: 8px;
  color: #475569;
  font-size: 15px;
}

.login-form-panel {
  width: min(460px, calc(100% - 64px));
  align-self: center;
  justify-self: center;
  padding: 0;
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-box p {
  margin: 0 0 28px;
  color: var(--muted);
}

.form-row {
  margin-bottom: 14px;
}

.app-shell {
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px 1fr;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  height: 100vh;
  overflow-y: auto;
  background: #202a38;
  color: #f9fafb;
  padding: 18px 14px;
  border-right: 1px solid #182231;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  padding: 8px 8px 18px;
}

.nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  margin-bottom: 6px;
  background: transparent;
  color: #d1d5db;
}

.nav button.active,
.nav button:hover {
  background: #243045;
  color: #fff;
}

.main {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f3f6fa;
}

.topbar {
  flex: 0 0 auto;
  z-index: 20;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.sticky-list-tools {
  position: sticky;
  top: 0;
  z-index: 18;
  margin: -2px 0 12px;
  padding: 2px 0 10px;
  background: #f3f6fa;
  border-bottom: 1px solid #dbe3ee;
  box-shadow: 0 10px 18px rgba(20, 30, 45, 0.08);
}

.sticky-list-tools .page-head {
  margin-bottom: 10px;
}

.sticky-list-tools .notice {
  margin-bottom: 8px;
}

.sticky-list-tools .panel {
  margin-bottom: 8px;
}

.orders-filter-panel.collapsed {
  display: none;
}

.sticky-filter-panel {
  position: sticky;
  top: 0;
  z-index: 15;
  background: #f3f6fa;
  box-shadow: 0 8px 14px rgba(20, 30, 45, 0.06);
}

.sticky-filter-bar {
  position: sticky;
  top: 0;
  z-index: 14;
  padding: 10px;
  margin: 0 0 12px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  box-shadow: 0 8px 14px rgba(20, 30, 45, 0.06);
}

.sticky-filter-panel .sticky-filter-bar {
  position: static;
  padding: 0;
  margin: 0;
  border: 0;
  box-shadow: none;
}

.sticky-table-tools {
  position: sticky;
  top: 0;
  z-index: 16;
  padding: 10px;
  margin: -2px 0 12px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  box-shadow: 0 8px 14px rgba(20, 30, 45, 0.06);
}

.sticky-table-tools .filters {
  margin: 0;
}

.table-top-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  height: 18px;
  margin-top: 8px;
  border: 1px solid #dbe3ee;
  border-radius: 6px;
  background: #f8fafc;
}

.table-top-scroll > div {
  height: 1px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0;
  font-size: 22px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.order-type-quick-filter {
  display: inline-grid;
  grid-template-columns: auto 132px;
  gap: 6px;
  align-items: center;
  min-height: 40px;
  margin: 0;
  color: #3f4b5f;
  font-size: 13px;
  font-weight: 800;
}

.order-type-quick-filter select {
  min-height: 34px;
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 700;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
}

.section-head select {
  width: auto;
  min-width: 120px;
}

.receivable-filters {
  margin-bottom: 12px;
}

.mini-table-wrap {
  max-width: 760px;
  margin-top: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.mini-table {
  min-width: 720px;
  font-size: 13px;
}

.mini-table th,
.mini-table td {
  padding: 8px;
}

.grid {
  display: grid;
  gap: 14px;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--text);
  text-align: left;
  font-weight: 800;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
}

.stat strong {
  font-size: 30px;
  font-weight: 900;
}

.stat-button {
  width: 100%;
  min-height: 92px;
  cursor: pointer;
}

.stat-button:hover {
  background: #f8fbff;
  border-color: #b8cef4;
}

.danger-stat {
  border-color: #f0aaa4;
  background: #fff5f4;
}

.danger-stat span,
.danger-stat strong {
  color: #b42318;
}

.overdue-stat {
  border-color: #7f1d1d;
  background: #fee2e2;
}

.overdue-stat span,
.overdue-stat strong {
  color: #7f1d1d;
}

.urgent-unfinished-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  margin-left: 6px;
  border-radius: 999px;
  background: #c9372c;
  color: #fff;
  font-size: 17px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.order-form-panel {
  padding: 10px 12px 12px;
  margin-bottom: 12px;
}

.order-paste-panel {
  padding: 12px;
  margin-bottom: 12px;
}

.embedded-paste-panel {
  grid-column: span 2;
  align-self: start;
  border: 1px solid #d7e0ec;
  border-radius: 6px;
  background: #f8fafc;
  margin-bottom: 0;
}

.order-paste-panel h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.order-paste-panel .form-row {
  margin-bottom: 10px;
}

.order-paste-panel textarea {
  min-height: 58px;
}

.compact-order-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px 10px;
}

.compact-order-grid > div:not(.full):not(.wide) {
  grid-column: span 3;
}

.compact-order-grid .wide {
  grid-column: span 6;
}

.compact-order-grid input,
.compact-order-grid select {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 14px;
}

.compact-order-grid textarea {
  min-height: 52px;
  padding: 6px 8px;
  font-size: 14px;
  line-height: 1.35;
}

.compact-order-grid label {
  margin-bottom: 3px;
  font-size: 12px;
}

.form-section-title {
  margin-top: 6px;
  padding: 6px 0 4px;
  border-top: 1px solid #d7e0ec;
  color: #172033;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.order-alert td {
  background: #fff5f4;
}

.order-alert.overdue-row td {
  background: #fee2e2;
  color: #7f1d1d;
}

.order-alert.due-row td {
  color: #8f1d16;
}

.shipment-paste {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 0.8fr);
  gap: 10px;
  align-items: stretch;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.shipment-paste-box {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.shipment-paste-box label {
  grid-column: 1 / -1;
}

.shipment-paste-box textarea {
  min-height: 58px;
}

.customer-shipping-summary {
  border: 1px solid #d7e0ec;
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
  cursor: pointer;
}

.customer-shipping-summary label {
  margin-bottom: 0;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.summary-head button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.summary-line {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  margin-bottom: 5px;
  font-size: 13px;
}

.summary-line span {
  color: var(--muted);
  font-weight: 700;
}

.summary-line strong {
  min-width: 0;
  overflow-wrap: anywhere;
  user-select: text;
}

.sensitive-input {
  letter-spacing: 1px;
}

.form-grid .form-section-title:first-child {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

.form-hint {
  margin-top: -4px;
  color: #44546a;
  font-size: 12px;
  line-height: 1.25;
}

.required {
  color: var(--danger);
  margin-left: 4px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .wide {
  grid-column: span 2;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid.compact-order-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px 10px;
}

.form-grid.compact-order-grid > div:not(.full):not(.wide) {
  grid-column: span 3;
}

.form-grid.compact-order-grid .wide {
  grid-column: span 6;
}

.form-grid.compact-order-grid .full {
  grid-column: 1 / -1;
}

.order-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.order-section {
  min-width: 0;
  border-top: 1px solid #d7e0ec;
  padding-top: 7px;
}

.order-section h3 {
  margin: 0 0 7px;
  color: #172033;
  font-size: 14px;
  line-height: 1.25;
}

.order-section.full-section {
  grid-column: 1 / -1;
}

.section-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px 8px;
}

.section-fields .wide {
  grid-column: 1 / -1;
}

.section-fields .span2 {
  grid-column: span 2;
}

.section-fields input,
.section-fields select {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 14px;
}

.section-fields textarea {
  min-height: 52px;
  padding: 6px 8px;
  font-size: 14px;
  line-height: 1.35;
}

.section-fields label {
  margin-bottom: 3px;
  font-size: 12px;
}

.product-fields {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px 8px;
}

.product-fields input,
.product-fields select {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 14px;
}

.product-fields textarea {
  min-height: 68px;
  padding: 6px 8px;
  font-size: 14px;
  line-height: 1.35;
}

.product-fields label {
  margin-bottom: 3px;
  font-size: 12px;
}

.product-fields .product-hint,
.product-fields .product-images {
  grid-column: 1 / -1;
}

.product-fields .process-field {
  grid-column: span 3;
}

.product-fields .process-field textarea {
  min-height: 96px;
}

.product-fields .process-editor {
  min-height: 104px;
  max-height: 210px;
  overflow: auto;
  border: 1.5px solid #b9c4d3;
  border-radius: 6px;
  padding: 7px 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.38;
  outline: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.product-fields .process-editor:focus {
  outline: 2px solid #b9d5ff;
  border-color: var(--primary);
}

.product-fields .printing-unit-field {
  grid-column: span 1;
  align-self: start;
}

.product-fields .inline-payment-section {
  grid-column: span 3;
}

.inline-payment-section h3 {
  margin: 0 0 5px;
  color: #172033;
  font-size: 13px;
  line-height: 1.25;
}

.inline-payment-fields {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px 6px;
}

.inline-payment-fields > div {
  grid-column: span 2;
}

.inline-payment-fields input,
.inline-payment-fields select {
  min-height: 30px;
  padding: 4px 7px;
  font-size: 12px;
}

.inline-payment-fields label {
  margin-bottom: 2px;
  font-size: 11px;
}

.inline-payment-fields .payment-emphasis label,
.inline-payment-fields .payment-emphasis select {
  color: #b42318;
}

.order-payment-select {
  max-width: 82px;
  min-height: 26px;
  padding: 2px 4px;
  font-size: 11px;
  line-height: 1.1;
}

.product-fields .product-hint {
  margin-top: -2px;
}

.product-images h3 {
  margin: 0 0 7px;
  color: #172033;
  font-size: 14px;
  line-height: 1.25;
}

.product-fields .product-images {
  grid-column: span 3;
}

.product-fields .printing-paper-stack,
.product-fields .printing-requirement-field,
.product-fields .buy-paper-detail-field,
.product-fields .knife-field {
  grid-column: span 1;
  align-self: start;
}

.product-fields .printing-requirement-field,
.product-fields .buy-paper-detail-field,
.product-fields .knife-field {
  border: 1px solid #f0aaa4;
  background: #fff5f4;
  border-radius: 6px;
  padding: 6px;
}

.product-fields .printing-paper-stack {
  display: grid;
  grid-template-rows: auto minmax(82px, 1fr);
  gap: 6px;
  align-self: stretch;
}

.printing-requirement-field label,
.buy-paper-detail-field label,
.knife-field label {
  color: #c9372c;
  font-size: 12px;
  font-weight: 900;
}

.printing-requirement-field select,
.buy-paper-detail-field textarea,
.knife-field select,
.knife-field input {
  min-height: 28px;
  padding: 3px 6px;
  font-size: 12px;
  border-color: #c9372c;
  color: #b42318;
  font-weight: 800;
}

.buy-paper-detail-field {
  display: grid;
  grid-template-rows: auto 1fr;
}

.buy-paper-detail-field textarea {
  min-height: 82px;
  resize: vertical;
}

.knife-field {
  display: grid;
  gap: 4px;
}

.knife-field input[type="file"] {
  padding: 3px 6px;
}

.knife-field button {
  min-height: 28px;
  padding: 0 8px;
}

.process-field label {
  color: #c9372c;
  font-size: 14px;
  font-weight: 900;
}

.image-section {
  padding-top: 8px;
}

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  vertical-align: top;
}

td.text-cell {
  max-width: 280px;
  white-space: normal;
  line-height: 1.5;
}

th {
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.orders-table-wrap {
  width: 100%;
  max-height: calc(100vh - 230px);
  overflow: auto;
  position: relative;
}

.orders-scroll-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: center;
  margin: 10px 0 8px;
}

.orders-scroll-btn {
  min-height: 34px;
  padding: 0;
  font-size: 22px;
  font-weight: 700;
}

.orders-top-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  height: 20px;
  border: 1px solid #dbe3ee;
  border-radius: 6px;
  background: #f8fafc;
}

.orders-top-scroll > div {
  height: 1px;
}

.orders-table {
  min-width: 0;
  table-layout: fixed;
}

.orders-table th,
.orders-table td {
  border: 1px solid #b8c4d4;
  border-top-color: #111827;
  border-bottom-color: #111827;
  padding: 5px 7px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: middle;
}

.orders-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  border-color: #9fb0c4;
  border-top-color: #111827;
  border-bottom-color: #111827;
  background: #e8f0f8;
  box-shadow: 0 1px 0 #9fb0c4, 0 2px 8px rgba(20, 30, 45, 0.1);
}

.orders-table tbody tr:nth-child(even) td {
  background: #f8fbff;
}

.orders-table tr:last-child td {
  border-bottom: 1px solid #111827;
}

.orders-table .order-col-date {
  width: 90px;
}

.orders-table .order-col-customer {
  width: 140px;
}

.orders-table .order-col-product {
  width: 220px;
}

.orders-table .order-col-type {
  width: 86px;
}

.orders-table .order-col-process {
  width: 520px;
}

.orders-table .order-col-qty {
  width: 62px;
}

.orders-table .order-col-unit {
  width: 64px;
}

.orders-table .order-col-total {
  width: 88px;
}

.orders-table .order-col-delivery {
  width: 90px;
}

.orders-table .order-col-production,
.orders-table .order-col-payment {
  width: 96px;
}

.orders-table .order-col-images {
  width: 58px;
}

.orders-table .order-col-sales {
  width: 76px;
}

.orders-table .order-col-actions {
  width: 230px;
}

.orders-table td.text-cell {
  max-width: 500px;
  font-weight: 700;
  line-height: 1.25;
}

.process-red {
  color: #d92d20;
  font-weight: 800;
}

.process-color-text {
  font-weight: 800;
}

.process-color-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap;
}

.process-color-swatch {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  border-radius: 5px;
  padding: 0;
  background: var(--swatch);
}

.process-color-swatch:hover {
  filter: brightness(0.92);
}

.process-preview {
  min-height: 32px;
  margin-top: 6px;
  border: 1px dashed #cbd7e6;
  border-radius: 6px;
  padding: 6px 8px;
  background: #fbfdff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.process-preview:empty::before {
  content: "标红预览";
  color: #7b8794;
  font-weight: 500;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.field-label-row label {
  margin: 0;
}

button.mini-btn {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}

.orders-table td:last-child {
  white-space: normal;
}

.orders-table button.link {
  min-height: 22px;
  padding: 0 3px;
  font-size: 12px;
}

.orders-table .status-select {
  width: 100%;
  max-width: 100%;
  min-height: 26px;
  padding: 3px 4px;
  font-size: 11px;
}

.orders-table .badge {
  min-height: 20px;
  padding: 0 6px;
  font-size: 11px;
}

.legacy-status-control {
  display: grid;
  gap: 4px;
  align-items: center;
}

.legacy-status-control .badge {
  justify-content: center;
}

.orders-table tr.row-flash td {
  animation: rowFlash 1.6s ease-out;
}

@keyframes rowFlash {
  0% { background: #fff7c2; }
  100% { background: inherit; }
}

.inline-editable-cell {
  cursor: text;
}

.inline-editable-cell:hover {
  box-shadow: inset 0 0 0 2px rgba(31, 111, 235, 0.18);
}

.inline-editing {
  padding: 4px !important;
  background: #f8fbff !important;
}

.inline-edit-wrap {
  display: grid;
  gap: 5px;
}

.inline-edit-input,
.inline-edit-process {
  width: 100%;
  min-height: 30px;
  border: 1.5px solid #8eb8ff;
  border-radius: 6px;
  padding: 5px 7px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.inline-edit-process {
  min-height: 76px;
  max-height: 190px;
  overflow: auto;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.inline-edit-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.blue {
  background: var(--soft-blue);
  color: #1d4ed8;
}

.badge.grass,
.status-select.grass {
  background: #ecfdf3;
  color: #237a35;
}

.badge.green {
  background: var(--soft-green);
  color: #166534;
}

.badge.purple,
.status-select.purple {
  background: #f2eafa;
  color: #6f35a5;
}

.badge.orange,
.status-select.orange {
  background: #fff3e6;
  color: #b45309;
}

.badge.orange-red,
.status-select.orange-red {
  background: #fff0e8;
  color: #c2410c;
}

.badge.red {
  background: var(--soft-red);
  color: #b42318;
}

.urgent-badge {
  padding: 3px 8px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
}

.badge.yellow {
  background: var(--soft-yellow);
  color: #92400e;
}

.badge.dark,
.status-select.dark {
  background: #e5e7eb;
  color: #111827;
}

.status-select {
  border-color: currentColor;
  font-weight: 700;
}

.status-select.blue {
  background: var(--soft-blue);
  color: #1d4ed8;
}

.status-select.green {
  background: var(--soft-green);
  color: #166534;
}

.status-select.red {
  background: var(--soft-red);
  color: #b42318;
}

.status-select.yellow {
  background: var(--soft-yellow);
  color: #92400e;
}

.muted {
  color: var(--muted);
}

.hidden-money {
  color: var(--muted);
  font-size: 13px;
}

.permission-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.check-item input {
  width: auto;
  min-height: auto;
}

.notice {
  background: #fff7e6;
  color: #7c4a03;
  border: 1px solid #f6d99b;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.option-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.option-editor-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.option-editor-title label {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.option-editor-grid {
  display: grid;
  grid-template-columns: 84px minmax(180px, 1fr) 180px 66px;
  gap: 6px;
  align-items: center;
}

.option-editor-header {
  padding: 5px 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  background: #eef4fb;
  border-radius: 5px;
}

.option-editor-rows,
.option-editor-row {
  display: contents;
}

.option-sort-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.option-editor-row input,
.option-editor-row select {
  min-height: 30px;
  padding: 4px 7px;
  font-size: 13px;
}

.option-color-control {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.option-color-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.18);
}

.option-color-dot.blue { background: var(--soft-blue); }
.option-color-dot.green { background: var(--soft-green); }
.option-color-dot.red { background: var(--soft-red); }
.option-color-dot.yellow { background: var(--soft-yellow); }
.option-color-dot.purple { background: #f2eafa; }
.option-color-dot.orange { background: #fff3e6; }
.option-color-dot.orange-red { background: #fff0e8; }
.option-color-dot.grass { background: #ecfdf3; }
.option-color-dot.dark { background: #e5e7eb; }

.app-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.app-dialog {
  width: min(420px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.28);
  padding: 18px;
}

.app-dialog h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.app-dialog-message {
  white-space: pre-wrap;
  color: #334155;
  line-height: 1.55;
}

.app-dialog-input {
  margin-top: 12px;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.image-upload {
  display: grid;
  grid-template-columns: 220px minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.image-paste-zone {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1.5px dashed #9fb6d8;
  border-radius: 8px;
  background: #f8fbff;
  color: #29405e;
  cursor: pointer;
}

.image-paste-zone strong {
  font-size: 14px;
}

.image-paste-zone span {
  color: #687386;
  font-size: 12px;
  line-height: 1.45;
}

.image-paste-zone:hover,
.image-paste-zone:focus,
.image-paste-zone.pasting {
  outline: 2px solid #b9d5ff;
  border-color: var(--primary);
  background: #eef6ff;
}

.image-upload-hint {
  grid-column: 1 / -1;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.image-card {
  border: 1px solid #d7e0ec;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.image-meta {
  display: grid;
  gap: 3px;
  margin: 8px 0;
  color: #4b5563;
  font-size: 12px;
}

.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.64);
}

.image-preview-dialog {
  width: min(1180px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.32);
}

.image-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.image-preview-head h3 {
  margin: 0;
  font-size: 16px;
}

.image-preview-body {
  overflow: auto;
  padding: 12px;
  background: #f8fafc;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.image-preview-card {
  min-width: 0;
  border: 1px solid #d7e0ec;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.image-preview-card img {
  display: block;
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  background: #fff;
}

.image-preview-meta {
  margin-top: 8px;
  color: #475569;
  font-size: 12px;
  line-height: 1.45;
}

.print-preview-dialog {
  width: min(1180px, calc(100vw - 36px));
  height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.32);
}

.print-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.workorder-image-dialog {
  width: min(1120px, calc(100vw - 36px));
  height: calc(100vh - 36px);
}

.workorder-image-stage {
  overflow: auto;
  padding: 18px;
  background: #e9eef5;
  text-align: center;
  cursor: zoom-in;
}

.workorder-image-preview {
  display: inline-block;
  height: auto;
  max-width: none;
  border: 1px solid #cbd5e1;
  background: #fff;
  box-shadow: 0 10px 35px rgba(15, 23, 42, 0.18);
}

.compact-table {
  margin-top: 10px;
}

.compact-table table {
  min-width: 760px;
}

.compact-table input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.finance-inline-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.finance-inline-form .actions {
  align-self: end;
}

.finance-period-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.finance-title-with-chart {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.finance-chart-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid #cfd8e6;
  border-radius: 6px;
  background: #fff;
  color: var(--primary);
}

.finance-chart-button:hover,
.finance-chart-button.active {
  border-color: var(--primary);
  background: #eef6ff;
}

.finance-chart-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
}

.finance-chart-button rect {
  fill: currentColor;
  stroke: none;
}

.finance-chart-panel {
  display: grid;
  gap: 8px;
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid #d9e2ef;
  border-radius: 8px;
  background: #fbfdff;
}

.finance-chart-row {
  display: grid;
  grid-template-columns: 48px minmax(110px, 1fr) 96px;
  gap: 8px;
  align-items: center;
}

.finance-chart-label {
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.finance-chart-track {
  display: block;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5edf7;
}

.finance-chart-bar {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #2563eb;
}

.finance-chart-row.expense .finance-chart-bar,
.finance-chart-mini.expense .finance-chart-bar {
  background: #d97706;
}

.finance-chart-row.profit .finance-chart-bar,
.finance-chart-mini.profit .finance-chart-bar {
  background: #16a34a;
}

.finance-chart-row.negative .finance-chart-bar,
.finance-chart-mini.negative .finance-chart-bar {
  background: #dc2626;
}

.finance-chart-value {
  text-align: right;
  font-size: 12px;
}

.finance-chart-legend {
  display: flex;
  gap: 10px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.finance-chart-legend span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 50%;
  background: #2563eb;
}

.finance-chart-legend .expense::before {
  background: #d97706;
}

.finance-chart-legend .profit::before {
  background: #16a34a;
}

.finance-chart-year-row {
  grid-template-columns: 56px minmax(0, 1fr);
}

.finance-chart-triple {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.finance-chart-mini {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: #64748b;
  font-size: 11px;
}

.finance-customer-group {
  margin-top: 10px;
}

.finance-customer-group summary {
  cursor: pointer;
  font-weight: 700;
}

.reimbursement-quick-grid .span2 {
  grid-column: span 4;
}

.form-grid.reimbursement-quick-grid {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.form-grid.reimbursement-quick-grid > div:not(.full):not(.wide):not(.span2) {
  grid-column: span 1;
}

.reimbursement-quick-grid textarea {
  min-height: 72px;
}

.compact-actions {
  margin-top: 6px;
}

.customer-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 220px));
  gap: 12px;
  margin-bottom: 14px;
}

.customer-form-grid {
  align-items: end;
}

.customer-copy-box {
  border: 1px solid #d7e0ec;
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
  margin-bottom: 12px;
}

.customer-copy-box textarea {
  min-height: 132px;
  background: #fff;
  line-height: 1.5;
  user-select: text;
}

.customer-detail-row td {
  background: #f8fafc;
  white-space: normal;
}

.customer-detail-row .section-head {
  margin-bottom: 8px;
}

.customer-form-grid .wide {
  grid-column: span 2;
}

.customer-form-grid .actions {
  align-self: end;
}

.customer-form-grid textarea {
  min-height: 64px;
}

.sub-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.sub-panel h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.quick-panel {
  border-color: #9fb9dc;
}

.quick-panel h3 {
  margin-top: 0;
}

.quick-panel input[type="file"] {
  padding: 10px;
  background: #f8fafc;
}

@media (min-width: 901px) and (max-width: 1200px) {
  .product-fields {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .product-fields .printing-requirement-field,
  .product-fields .knife-field {
    grid-column: span 1;
  }

  .form-grid.compact-order-grid > div:not(.full):not(.wide) {
    grid-column: span 4;
  }

  .form-grid.compact-order-grid .wide {
    grid-column: span 8;
  }
}

@media (max-width: 900px) {
  .login-box {
    grid-template-columns: 1fr;
  }

  .login-identity {
    min-height: auto;
    padding: 22px 24px;
    border-right: 0;
    border-bottom: 1px solid #182231;
  }

  .login-form-panel {
    width: min(460px, calc(100% - 32px));
    padding: 28px 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    overflow: visible;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    gap: 6px;
  }

  .nav button {
    width: auto;
    white-space: nowrap;
    min-height: 46px;
  }

  .topbar {
    height: auto;
    padding: 12px 16px;
    align-items: flex-start;
  }

  .main {
    height: auto;
    display: block;
    overflow: visible;
  }

  .content {
    overflow: visible;
    padding: 16px;
  }

  .sticky-list-tools,
  .sticky-filter-panel,
  .sticky-filter-bar,
  .sticky-table-tools {
    position: static;
    top: auto;
    z-index: auto;
    box-shadow: none;
  }

  .sticky-list-tools {
    margin: 0 0 12px;
    padding: 0;
    border-bottom: 0;
    background: transparent;
  }

  .sticky-table-tools {
    margin: 0 0 12px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .orders-table-wrap {
    max-height: none;
  }

  .orders-table thead th {
    position: static;
    box-shadow: none;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats,
  .filters,
  .finance-period-row,
  .form-grid,
  .compact-order-grid,
  .form-grid.compact-order-grid,
  .order-section-grid,
  .section-fields,
  .product-fields,
  .inline-payment-fields,
  .permission-list,
  .image-upload,
  .image-grid,
  .customer-summary,
  .shipment-paste-box,
  .shipment-paste {
    grid-template-columns: 1fr;
  }

  .form-grid .wide,
  .form-grid.compact-order-grid .wide,
  .form-grid.compact-order-grid .full,
  .form-grid.compact-order-grid > div:not(.full):not(.wide),
  .order-section.full-section,
  .section-fields .wide,
  .section-fields .span2,
  .product-fields .product-hint,
  .product-fields .process-field,
  .product-fields .printing-unit-field,
  .product-fields .product-images,
  .embedded-paste-panel,
  .product-fields .inline-payment-section,
  .product-fields .printing-paper-stack,
  .product-fields .printing-requirement-field,
  .product-fields .buy-paper-detail-field,
  .product-fields .knife-field,
  .compact-order-grid .wide,
  .compact-order-grid > div:not(.full):not(.wide),
  .form-grid .full {
    grid-column: auto;
  }

  button,
  input,
  select,
  textarea {
    min-height: 46px;
  }

  .brand {
    padding-bottom: 10px;
    font-size: 16px;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar .actions,
  .page-head .actions,
  .section-head .actions,
  .filters .actions {
    width: 100%;
  }

  .topbar .actions button,
  .page-head .actions button,
  .filters .actions button {
    flex: 1 1 140px;
  }

  .finance-chart-row,
  .finance-chart-year-row {
    grid-template-columns: 1fr;
  }

  .finance-chart-triple {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .image-preview-overlay {
    padding: 10px;
  }

  .image-preview-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .image-preview-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px;
  }

  td.text-cell {
    min-width: 180px;
  }

  .panel,
  .order-section,
  .order-paste-panel {
    border-radius: 6px;
  }

  .app-dialog {
    width: min(460px, calc(100vw - 24px));
    padding: 16px;
  }
}

@media (max-width: 640px) {
  .sidebar {
    padding: 10px;
  }

  .content {
    padding: 12px;
  }

  .login-page {
    padding: 14px;
  }

  .login-box {
    width: 100%;
  }

  .nav button {
    min-height: 44px;
    padding: 0 12px;
  }

  .page-head h2 {
    font-size: 20px;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .actions button,
  .section-head .actions button,
  .app-dialog-actions button {
    flex: 1 1 100%;
  }

  .filters {
    gap: 10px;
  }

  .compact-table table,
  table {
    min-width: 760px;
  }

  .order-form-panel,
  .panel {
    padding: 12px;
  }

  .image-grid img,
  .image-card img {
    max-height: 220px;
    object-fit: contain;
  }
}
