:root {
  color-scheme: light;
  --canvas: #f5f6f4;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --ink: #202522;
  --ink-soft: #424a45;
  --muted: #737b76;
  --line: #dde2de;
  --line-strong: #cbd2cd;
  --sidebar: #252b27;
  --sidebar-soft: #303832;
  --sidebar-text: #f5f7f5;
  --sidebar-muted: #aeb8b0;
  --sage: #587362;
  --sage-strong: #415b4a;
  --sage-soft: #e8efea;
  --rose: #a96568;
  --rose-soft: #f7eaea;
  --amber: #9a6a2f;
  --amber-soft: #fff3df;
  --blue: #4c6985;
  --blue-soft: #eaf1f7;
  --danger: #a94747;
  --danger-soft: #faeaea;
  --shadow-sm: 0 1px 2px rgba(29, 39, 32, .05);
  --shadow-lg: 0 24px 70px rgba(26, 35, 29, .2);
  --radius: 7px;
  --sidebar-width: 248px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

body.drawer-open,
body.nav-open {
  overflow: hidden;
}

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

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  touch-action: manipulation;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

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

:focus-visible {
  outline: 3px solid rgba(88, 115, 98, .25);
  outline-offset: 2px;
}

.noscript {
  padding: 12px 18px;
  color: #fff;
  background: var(--danger);
  text-align: center;
}

.toast-region {
  position: fixed;
  z-index: 90;
  right: 22px;
  top: 20px;
  display: grid;
  width: min(380px, calc(100vw - 32px));
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--sage);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(25, 34, 28, .16);
  animation: toast-in .22s ease-out;
  pointer-events: auto;
}

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

.toast svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--sage);
}

.toast.error svg {
  color: var(--danger);
}

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  margin-bottom: 2px;
  font-size: 13px;
}

.toast span {
  color: var(--ink-soft);
  font-size: 12px;
}

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

.auth-view {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(420px, 44%) 1fr;
  background: var(--surface);
}

.login-panel {
  display: flex;
  width: min(100%, 510px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 44px 64px 34px;
  flex-direction: column;
}

.login-brand,
.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--sage);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.7;
}

.login-brand strong,
.login-brand small,
.sidebar-brand strong,
.sidebar-brand small {
  display: block;
  letter-spacing: 0;
}

.login-brand strong,
.sidebar-brand strong {
  font-size: 16px;
  line-height: 1.3;
}

.login-brand small,
.sidebar-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.login-copy {
  margin-top: auto;
  padding-top: 82px;
}

.login-copy h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.25;
  font-weight: 650;
}

.login-copy p {
  margin: 10px 0 0;
  color: var(--muted);
}

.login-panel > .form-stack {
  margin-top: 32px;
}

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

.field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.field > span:first-child,
.field > label:first-child {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.field em {
  color: var(--danger);
  font-style: normal;
}

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

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

input:hover,
textarea:hover,
select:hover {
  border-color: #afb8b1;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--sage);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(88, 115, 98, .12);
}

input::placeholder,
textarea::placeholder {
  color: #a0a7a2;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 45px;
}

.password-field .icon-button {
  position: absolute;
  right: 4px;
  top: 3px;
}

.form-message {
  margin: 0;
  padding: 9px 11px;
  border-left: 3px solid var(--danger);
  color: #7d3333;
  background: var(--danger-soft);
  font-size: 12px;
}

.form-message.success {
  border-left-color: var(--sage);
  color: var(--sage-strong);
  background: var(--sage-soft);
}

.back-link {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 7px;
  margin-top: auto;
  padding-top: 58px;
  color: var(--muted);
  font-size: 12px;
}

.back-link:hover {
  color: var(--sage-strong);
}

.back-link svg {
  width: 15px;
  height: 15px;
}

.login-aside {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(30, 40, 33, .25), rgba(30, 40, 33, .05)),
    url("../images/yueji-hero.png") center / cover no-repeat,
    #d8ded9;
}

.login-aside::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, transparent 56%, rgba(25, 33, 28, .7));
}

.login-aside-copy {
  position: absolute;
  z-index: 1;
  right: 7vw;
  bottom: 7vh;
  left: 7vw;
  max-width: 640px;
  color: #fff;
}

.login-aside-copy span,
.login-aside-copy strong {
  display: block;
}

.login-aside-copy span {
  margin-bottom: 13px;
  font: 12px/1.4 Georgia, "Times New Roman", serif;
}

.login-aside-copy strong {
  font-size: clamp(25px, 3vw, 42px);
  line-height: 1.35;
  font-weight: 550;
}

.button,
.icon-button,
.text-button,
.nav-item,
.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: color .16s ease, background-color .16s ease, border-color .16s ease, opacity .16s ease;
}

.button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.button svg,
.text-button svg {
  width: 16px;
  height: 16px;
}

.button.primary {
  color: #fff;
  background: var(--sage-strong);
}

.button.primary:hover {
  background: #334b3b;
}

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

.button.secondary:hover {
  border-color: #aab4ac;
  background: var(--surface-soft);
}

.button.danger {
  color: #fff;
  background: var(--danger);
}

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

.button:disabled,
.icon-button:disabled,
.table-action:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.button.loading svg {
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-soft);
  background: var(--surface);
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.icon-button.compact {
  width: 34px;
  height: 34px;
  border-color: transparent;
  background: transparent;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

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

.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  padding: 24px 16px 17px;
  flex-direction: column;
  color: var(--sidebar-text);
  background: var(--sidebar);
}

.sidebar-brand {
  min-height: 48px;
  padding: 0 9px;
}

.sidebar-brand .brand-mark {
  width: 35px;
  height: 35px;
  color: var(--sidebar);
  background: #e7ede8;
}

.sidebar-brand .brand-mark svg {
  width: 18px;
  height: 18px;
}

.sidebar-brand strong {
  color: var(--sidebar-text);
}

.sidebar-brand small {
  color: var(--sidebar-muted);
}

.side-nav {
  display: grid;
  gap: 5px;
  margin-top: 42px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  justify-content: flex-start;
  border-radius: 6px;
  color: var(--sidebar-muted);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.nav-item:hover {
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, .06);
}

.nav-item.active {
  color: #fff;
  background: var(--sidebar-soft);
  box-shadow: inset 3px 0 #aabcae;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, .09);
}

.signed-user {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 0 8px 15px;
}

.signed-user > span:last-child {
  min-width: 0;
}

.signed-user strong,
.signed-user small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.signed-user strong {
  font-size: 12px;
  font-weight: 600;
}

.signed-user small {
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 10px;
}

.user-avatar,
.mobile-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--sidebar);
  background: #d8e1da;
  font-size: 12px;
  font-weight: 700;
}

.user-avatar {
  width: 32px;
  height: 32px;
}

.nav-item.subtle {
  min-height: 36px;
  font-size: 12px;
}

.sidebar-scrim,
.mobile-header {
  display: none;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 36px clamp(24px, 3.3vw, 52px) 58px;
}

.workspace-head {
  display: flex;
  min-height: 58px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 27px;
}

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

.workspace-head h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.3;
  font-weight: 650;
}

.workspace-actions {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 9px;
}

.view {
  min-width: 0;
}

.stats-grid {
  display: grid;
  overflow: hidden;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-item {
  min-width: 0;
  padding: 20px 21px;
  border-right: 1px solid var(--line);
}

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

.stat-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.stat-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--sage-strong);
  background: var(--sage-soft);
}

.stat-icon.rose {
  color: var(--rose);
  background: var(--rose-soft);
}

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

.stat-icon.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.stat-icon svg {
  width: 15px;
  height: 15px;
}

.stat-value {
  display: block;
  overflow: hidden;
  margin-top: 13px;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 650;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.stat-hint {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.content-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(270px, .65fr);
  gap: 20px;
  margin-top: 20px;
}

.content-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.section-heading {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2,
.drawer-head h2,
.confirm-dialog h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 650;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.text-button {
  padding: 7px 3px;
  color: var(--sage-strong);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

.text-button:hover {
  color: #2e4937;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.content-section .table-wrap {
  border: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: none;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  table-layout: fixed;
}

.compact-table table {
  min-width: 620px;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid #e9ecea;
  text-align: left;
  vertical-align: middle;
}

th {
  height: 44px;
  color: var(--muted);
  background: #fafbfa;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

td {
  height: 62px;
  color: var(--ink-soft);
  font-size: 12px;
}

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

tbody tr:hover td {
  background: #fbfcfb;
}

.cell-main,
.cell-sub {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cell-main {
  color: var(--ink);
  font-weight: 600;
}

.cell-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.money {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.product-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.product-thumb {
  display: grid;
  overflow: hidden;
  width: 42px;
  height: 42px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #8c958f;
  background: #eef1ef;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-thumb svg {
  width: 17px;
  height: 17px;
}

.product-copy {
  min-width: 0;
}

.badge {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: #edf0ee;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.pending,
.badge.preparing {
  color: #805621;
  background: var(--amber-soft);
}

.badge.confirmed,
.badge.delivering {
  color: #3f607c;
  background: var(--blue-soft);
}

.badge.completed,
.badge.active {
  color: #3c6048;
  background: var(--sage-soft);
}

.badge.cancelled,
.badge.inactive {
  color: #8b4747;
  background: var(--danger-soft);
}

.featured-mark {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  color: var(--rose);
  font-size: 10px;
}

.featured-mark svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

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

.pagination {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
}

.pagination span {
  margin: 0 4px;
  color: var(--muted);
  font-size: 11px;
}

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

.table-action {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
}

.table-action:hover {
  color: var(--sage-strong);
  background: var(--sage-soft);
}

.table-action.danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.table-action svg {
  width: 16px;
  height: 16px;
}

.priority-list {
  padding: 6px 18px;
}

.priority-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
  min-height: 64px;
  padding: 10px 0;
  border-bottom: 1px solid #e9ecea;
  cursor: pointer;
}

.priority-item:last-child {
  border-bottom: 0;
}

.priority-item:hover .cell-main {
  color: var(--sage-strong);
}

.priority-arrow {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--muted);
}

.toolbar {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.order-view-bar {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #edf0ee;
}

.segmented-control button {
  min-height: 32px;
  padding: 0 14px;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.segmented-control button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-field,
.select-field {
  position: relative;
  display: block;
  min-width: 0;
}

.search-field {
  width: min(320px, 100%);
}

.search-field > svg {
  position: absolute;
  z-index: 1;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

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

.select-field {
  width: 154px;
}

.select-field select {
  padding-right: 34px;
  appearance: none;
}

.select-field > svg {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 15px;
  height: 15px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.month-field {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding-left: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  white-space: nowrap;
}

.month-field input {
  width: 132px;
  height: 40px;
  padding: 0 9px 0 0;
  border: 0;
  background: transparent;
  font-size: 12px;
}

.month-field input:focus {
  box-shadow: none;
}

.orders-table {
  min-width: 960px;
}

.order-date,
.order-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.archive-note {
  margin: 0;
  border-left-color: var(--sage);
  background: var(--sage-soft);
}

.result-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.section-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 14px;
  padding: 10px 13px;
  border-left: 3px solid var(--blue);
  color: var(--ink-soft);
  background: var(--blue-soft);
  font-size: 12px;
}

.section-note svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.state-box {
  display: grid;
  min-height: 280px;
  padding: 36px 20px;
  place-items: center;
  align-content: center;
  color: var(--muted);
  text-align: center;
}

.compact-table .state-box,
.priority-list .state-box {
  min-height: 190px;
}

.state-box svg {
  width: 28px;
  height: 28px;
  margin-bottom: 12px;
  color: #9aa39c;
}

.state-box .state-spinner {
  animation: spin .8s linear infinite;
}

.state-box strong,
.state-box span {
  display: block;
}

.state-box strong {
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 13px;
}

.state-box span {
  max-width: 340px;
  font-size: 11px;
}

.state-box .button {
  margin-top: 14px;
}

.drawer-backdrop {
  position: fixed;
  z-index: 59;
  inset: 0;
  background: rgba(24, 30, 26, .36);
  animation: fade-in .18s ease-out;
}

.drawer {
  position: fixed;
  z-index: 60;
  inset: 0 0 0 auto;
  display: flex;
  width: min(620px, 100vw);
  min-width: 0;
  flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: drawer-in .22s ease-out;
}

.drawer.narrow {
  width: min(480px, 100vw);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes drawer-in {
  from { transform: translateX(30px); opacity: .6; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-head {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}

.drawer-head p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 10px;
}

.drawer-form,
.drawer-body {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

.drawer-form {
  display: flex;
  padding: 22px;
  flex-direction: column;
}

.drawer-body {
  padding: 22px;
}

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

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

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

.form-select {
  width: 100%;
}

.image-editor {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 15px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.image-preview {
  display: grid;
  overflow: hidden;
  width: 128px;
  aspect-ratio: 1;
  place-items: center;
  align-content: center;
  gap: 7px;
  border: 1px dashed var(--line-strong);
  border-radius: 5px;
  color: var(--muted);
  background: var(--surface);
  text-align: center;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview svg {
  width: 24px;
  height: 24px;
}

.image-preview span {
  padding: 0 8px;
  font-size: 10px;
}

.image-inputs {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 12px;
}

.upload-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.upload-row > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.switch-group {
  display: grid;
  overflow: hidden;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.switch-row {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  cursor: pointer;
}

.switch-row:first-child {
  border-right: 1px solid var(--line);
}

.switch-row.single {
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

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

.switch-row strong {
  color: var(--ink-soft);
  font-size: 12px;
}

.switch-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  display: block;
  width: 36px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #c8ceca;
  transition: background-color .16s ease;
}

.switch::after {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  content: "";
  background: #fff;
  box-shadow: 0 1px 3px rgba(31, 40, 34, .22);
  transition: transform .16s ease;
}

.switch-row input:checked + .switch {
  background: var(--sage);
}

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

.switch-row input:focus-visible + .switch {
  outline: 3px solid rgba(88, 115, 98, .25);
  outline-offset: 2px;
}

.drawer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin: auto -22px -22px;
  padding: 15px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.drawer-form > .form-message {
  margin-top: 18px;
}

.detail-loading {
  min-height: calc(100vh - 130px);
}

.order-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 18px;
  padding-bottom: 19px;
  border-bottom: 1px solid var(--line);
}

.order-summary h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
}

.order-summary p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.detail-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
}

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

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 24px;
}

.detail-field span,
.detail-field strong {
  display: block;
}

.detail-field span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
}

.detail-field strong {
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.order-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  min-height: 54px;
  padding: 9px 0;
  border-bottom: 1px solid #edf0ee;
}

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

.order-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 15px;
}

.order-total strong {
  font-size: 17px;
}

.status-update {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.status-update .select-field {
  width: 100%;
}

.confirm-dialog {
  width: min(400px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.confirm-dialog::backdrop {
  background: rgba(24, 30, 26, .45);
}

.confirm-dialog form {
  padding: 24px;
}

.dialog-icon {
  display: grid;
  width: 38px;
  height: 38px;
  margin-bottom: 15px;
  place-items: center;
  border-radius: 50%;
  color: var(--danger);
  background: var(--danger-soft);
}

.dialog-icon svg {
  width: 19px;
  height: 19px;
}

.confirm-dialog p {
  margin: 10px 0 22px;
  color: var(--ink-soft);
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

@media (max-width: 1120px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

  .priority-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
  }
}

@media (max-width: 900px) {
  .auth-view {
    grid-template-columns: minmax(0, 1fr);
  }

  .login-aside {
    display: none;
  }

  .login-panel {
    min-height: 100vh;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    z-index: 39;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(24, 30, 26, .38);
  }

  body.nav-open .sidebar-scrim {
    display: block;
  }

  .mobile-header {
    position: sticky;
    z-index: 30;
    top: 0;
    display: grid;
    height: 60px;
    padding: 0 16px;
    grid-template-columns: 38px minmax(0, 1fr) 32px;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(12px);
  }

  .mobile-brand {
    overflow: hidden;
    font-size: 14px;
    font-weight: 650;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .mobile-avatar {
    width: 30px;
    height: 30px;
  }

  .workspace {
    margin-left: 0;
    padding: 27px 22px 48px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .search-field {
    flex: 1 1 280px;
  }

  .result-count {
    flex: 1 0 100%;
    margin: 0;
  }
}

@media (max-width: 640px) {
  .toast-region {
    right: 16px;
    top: 12px;
  }

  .login-panel {
    width: 100%;
    padding: 27px 24px 25px;
  }

  .login-copy {
    padding-top: 70px;
  }

  .login-copy h1 {
    font-size: 27px;
  }

  .workspace {
    padding: 23px 16px 42px;
  }

  .workspace-head {
    min-height: auto;
    align-items: flex-end;
    margin-bottom: 21px;
  }

  .workspace-head h1 {
    font-size: 21px;
  }

  .workspace-actions .button span.optional-label {
    display: none;
  }

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

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

  .stat-item:nth-child(-n + 3) {
    border-bottom: 1px solid var(--line);
  }

  .stat-item {
    display: grid;
    padding: 16px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 3px 16px;
  }

  .stat-label {
    grid-column: 1;
  }

  .stat-icon {
    display: none;
  }

  .stat-value {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin-top: 0;
    font-size: 22px;
    text-align: right;
  }

  .stat-hint {
    grid-column: 1;
    margin-top: 0;
  }

  .priority-list {
    display: block;
  }

  .toolbar .search-field,
  .toolbar .select-field,
  .toolbar .month-field {
    width: 100%;
    flex: 1 1 100%;
  }

  .month-field input {
    width: 100%;
  }

  .order-view-bar,
  .segmented-control {
    width: 100%;
  }

  .order-toolbar .button {
    width: 100%;
  }

  .drawer {
    top: 0;
    width: 100vw;
  }

  .drawer-head {
    min-height: 68px;
    padding: 13px 16px;
  }

  .drawer-form,
  .drawer-body {
    padding: 18px 16px;
  }

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

  .span-2 {
    grid-column: span 1;
  }

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

  .image-preview {
    width: 92px;
  }

  .upload-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .switch-group {
    grid-template-columns: minmax(0, 1fr);
  }

  .switch-row:first-child {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .drawer-actions {
    margin: auto -16px -18px;
    padding: 13px 16px;
  }

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

  .status-update {
    grid-template-columns: minmax(0, 1fr);
  }

  .status-update .button {
    width: 100%;
  }
}

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