:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
  font-synthesis: none;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-muted: #f7f8f6;
  --ink: #202723;
  --muted: #69736d;
  --border: #d8ded9;
  --border-strong: #bcc7bf;
  --accent: #2f6b4f;
  --accent-strong: #244f3d;
  --accent-soft: #e7f0eb;
  --amber: #9a681d;
  --amber-soft: #f7edda;
  --blue: #426577;
  --blue-soft: #e8f0f3;
  --red: #9a403b;
  --red-soft: #f7e9e7;
  --shadow: 0 12px 32px rgba(34, 50, 41, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 107, 79, 0.28);
  outline-offset: 2px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.boot-screen {
  display: grid;
  min-height: 100dvh;
  place-content: center;
  justify-items: center;
  gap: 18px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  background: var(--accent-strong);
  font-size: 20px;
  font-weight: 800;
}

.boot-lines {
  display: grid;
  width: 150px;
  gap: 8px;
}

.boot-lines span,
.skeleton-line {
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, #dde2dd 20%, #eef1ed 45%, #dde2dd 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

.boot-lines span:last-child {
  width: 68%;
  justify-self: center;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

.login-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: minmax(300px, 0.9fr) minmax(440px, 1.1fr);
}

.login-brand {
  display: grid;
  align-content: space-between;
  min-height: 100%;
  padding: 48px;
  color: #ffffff;
  background: #244f3d;
}

.login-brand__identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand__identity .brand-mark {
  color: var(--accent-strong);
  background: #ffffff;
}

.login-brand h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: 0;
}

.login-brand p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

.login-brand__date {
  color: rgba(255, 255, 255, 0.64);
  font-size: 13px;
}

.login-panel {
  display: grid;
  align-content: center;
  width: min(100%, 560px);
  padding: 42px clamp(24px, 6vw, 78px);
}

.login-panel h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: 0;
}

.login-panel__subhead {
  margin: 10px 0 28px;
  color: var(--muted);
  line-height: 1.6;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field label,
.field-label {
  color: #3e4943;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.item-editor select,
.item-editor input,
.search-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  padding: 9px 11px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.item-editor select:hover,
.item-editor input:hover,
.search-field input:hover {
  border-color: #8fa094;
}

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

.field-error {
  min-height: 18px;
  color: var(--red);
  font-size: 12px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 8px 13px;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, transform 100ms ease;
}

.button:active,
.icon-button:active,
.segment-button:active {
  transform: scale(0.98);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button--primary {
  color: #ffffff;
  background: var(--accent);
}

.button--primary:hover {
  background: var(--accent-strong);
}

.button--secondary {
  border-color: var(--border-strong);
  color: var(--ink);
  background: var(--surface);
}

.button--secondary:hover {
  border-color: #93a198;
  background: var(--surface-muted);
}

.button--danger {
  border-color: #e0b8b4;
  color: var(--red);
  background: var(--red-soft);
}

.button--wide {
  width: 100%;
  min-height: 46px;
}

.app-shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  min-height: 66px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  padding: 10px max(18px, calc((100vw - 1400px) / 2));
  backdrop-filter: blur(12px);
}

.topbar__brand,
.topbar__user,
.live-state {
  display: flex;
  align-items: center;
}

.topbar__brand {
  gap: 11px;
  min-width: 0;
}

.topbar__brand strong,
.topbar__brand span,
.topbar__user strong,
.topbar__user span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.topbar__user {
  min-width: 0;
  justify-content: flex-end;
  gap: 10px;
  text-align: right;
}

.live-state {
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.live-state__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.live-state.is-live .live-state__dot {
  background: #3a805c;
  animation: breathe 2.2s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    opacity: 0.45;
    transform: scale(0.82);
  }
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  flex: 0 0 38px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: #46534b;
  background: var(--surface);
  transition: background 150ms ease, border-color 150ms ease, transform 100ms ease;
}

.icon-button:hover {
  border-color: #9eaaa2;
  background: var(--surface-muted);
}

.icon-button--danger {
  color: var(--red);
}

.workspace {
  width: min(100%, 1400px);
  margin: 0 auto;
  padding: 24px 18px 52px;
}

.workspace-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.workspace-title h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.25;
  letter-spacing: 0;
}

.workspace-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.summary-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.summary-item {
  min-width: 0;
  padding: 15px 17px;
  border-right: 1px solid var(--border);
}

.summary-item:last-child {
  border-right: 0;
}

.summary-item span,
.summary-item strong {
  display: block;
}

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

.summary-item strong {
  margin-top: 3px;
  font-size: 22px;
  line-height: 1.2;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
}

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

.search-field {
  position: relative;
  max-width: 420px;
}

.search-field .icon {
  position: absolute;
  top: 50%;
  left: 11px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-field input {
  padding-left: 38px;
}

.segments {
  display: flex;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.segments::-webkit-scrollbar {
  display: none;
}

.segment-button {
  min-height: 32px;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  padding: 5px 10px;
  white-space: nowrap;
  transition: color 150ms ease, background 150ms ease, transform 100ms ease;
}

.segment-button.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 700;
}

.order-surface {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.order-head,
.order-row {
  display: grid;
  grid-template-columns: 160px 100px minmax(260px, 1fr) 112px 104px 188px;
  align-items: center;
  gap: 14px;
}

.order-head {
  min-height: 40px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-muted);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
}

.order-row {
  min-height: 88px;
  border-bottom: 1px solid var(--border);
  padding: 13px 14px;
}

.order-row:last-child {
  border-bottom: 0;
}

.order-row:hover {
  background: #fafbf9;
}

.order-number {
  display: inline-flex;
  max-width: 100%;
  border: 0;
  color: var(--accent-strong);
  background: transparent;
  padding: 0;
  font-weight: 800;
  text-align: left;
}

.order-meta,
.order-time,
.print-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.print-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.print-cell .button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 12px;
}

.item-summary {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.item-summary__line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 0;
  font-size: 13px;
}

.item-summary__line span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-summary__line strong {
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

.status-picking {
  color: var(--blue);
  background: var(--blue-soft);
}

.status-ready {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.status-completed {
  color: #4e5b53;
  background: #e9ece9;
}

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

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.row-actions .button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 12px;
}

.empty-state,
.error-state,
.loading-list {
  display: grid;
  min-height: 270px;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.empty-state .icon,
.error-state .icon {
  width: 34px;
  height: 34px;
  color: #819087;
}

.loading-list {
  align-content: start;
}

.skeleton-row {
  display: grid;
  width: min(100%, 860px);
  grid-template-columns: 140px 100px 1fr 100px;
  gap: 18px;
  padding: 12px 0;
}

.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  color: #6c4b18;
  background: var(--amber-soft);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  align-items: stretch;
  justify-items: end;
  background: rgba(24, 32, 27, 0.42);
}

.drawer {
  display: grid;
  width: min(100%, 680px);
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: slide-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
}

.drawer__header,
.drawer__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding: 16px 18px;
}

.drawer__footer {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.drawer__header h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

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

.drawer__body {
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}

.item-editors {
  display: grid;
  gap: 10px;
}

.item-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 9px;
  align-items: end;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.item-editor__field {
  display: grid;
  gap: 6px;
}

.item-editor__catalog {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  min-width: 0;
}

.item-editor__field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-select-row {
  display: grid;
  gap: 7px;
}

.product-select-row--name {
  grid-template-columns: minmax(0, 1fr) 38px;
}

.product-select-row--specification {
  grid-template-columns: minmax(0, 1fr) 38px 38px;
}

.form-section {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

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

.section-heading h3 {
  margin: 0;
  font-size: 14px;
}

.section-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.section-actions .button {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
}

.modal-backdrop--front {
  z-index: 60;
}

.product-drawer {
  width: min(100%, 460px);
}

.operator-drawer {
  width: min(100%, 520px);
}

.operator-list {
  display: grid;
}

.operator-form {
  display: grid;
  gap: 7px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.operator-form:first-child {
  padding-top: 0;
}

.operator-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.operator-form__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.operator-form__controls input {
  min-width: 0;
}

.settings-summary {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.settings-summary > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
}

.settings-summary dt {
  color: var(--muted);
}

.settings-summary dd {
  margin: 0;
  font-weight: 800;
}

.detail-list {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--border);
}

.detail-list > div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
  font-weight: 700;
}

.detail-items {
  margin-top: 22px;
}

.detail-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding: 12px 0;
}

.detail-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong:last-child {
  white-space: nowrap;
}

.toast-region {
  position: fixed;
  z-index: 80;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  animation: toast-in 170ms ease-out;
}

.toast.is-error {
  border-left-color: var(--red);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (max-width: 980px) {
  .order-head,
  .order-row {
    grid-template-columns: 145px 86px minmax(220px, 1fr) 96px 165px;
  }

  .order-head > :nth-child(5),
  .order-row > :nth-child(5) {
    display: none;
  }

  .toolbar {
    grid-template-columns: 1fr auto;
  }

  .segments {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 760px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: auto;
    padding: 22px 20px;
  }

  .login-brand__date {
    display: none;
  }

  .login-panel {
    align-content: start;
    padding: 34px 20px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 9px 12px;
  }

  .live-state {
    position: absolute;
    top: 51px;
    left: 0;
    width: 100%;
    min-height: 28px;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .topbar__user > div {
    display: none;
  }

  .workspace {
    padding: 42px 12px 38px;
  }

  .workspace-title {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-title .button {
    width: 100%;
  }

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

  .summary-item:nth-child(2) {
    border-right: 0;
  }

  .summary-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

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

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions .button {
    flex: 1;
  }

  .search-field {
    max-width: none;
  }

  .toolbar > .button {
    width: 100%;
  }

  .segments {
    grid-column: auto;
    grid-row: auto;
  }

  .order-head {
    display: none;
  }

  .order-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 14px;
    padding: 14px;
  }

  .order-row > :nth-child(3) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .order-row > :nth-child(4) {
    grid-column: 2;
    grid-row: 1;
  }

  .order-row > :nth-child(5) {
    display: block;
    grid-column: 1;
    grid-row: 3;
  }

  .order-row > :nth-child(6) {
    grid-column: 1 / -1;
    grid-row: 4;
  }

  .order-row > :nth-child(2) {
    grid-column: 1;
    grid-row: 1;
    padding-top: 25px;
  }

  .order-row > :nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions .button {
    flex: 1;
  }

  .drawer {
    width: 100%;
  }

  .item-editor {
    grid-template-columns: minmax(0, 1fr) 88px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-actions {
    width: 100%;
    justify-content: stretch;
  }

  .section-actions .button {
    flex: 1;
  }
}

@media (max-width: 430px) {
  .login-brand h1 {
    font-size: 18px;
  }

  .topbar__brand .brand-mark {
    width: 36px;
    height: 36px;
  }

  .topbar__brand strong {
    max-width: 178px;
  }

  .summary-item {
    padding: 12px;
  }

  .item-editor {
    grid-template-columns: 1fr;
  }

  .item-editor__catalog {
    grid-template-columns: 1fr;
  }

  .item-editor__field:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .operator-form__controls {
    grid-template-columns: 1fr;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
