/* Notion 设计语言（见 DESIGN.md）：暖纸画布 + 近黑 Inter + 单一 Notion 蓝。 */
:root {
  color-scheme: light;
  --canvas: #f6f5f4;
  --surface: #ffffff;
  --ink: rgba(0, 0, 0, .95);
  --ink-secondary: #31302e;
  --ink-muted: #615d59;
  --ink-faint: #a39e98;
  --hairline: #e6e6e6;
  --hairline-strong: #d9d9d8;
  --primary: #0075de;
  --primary-active: #005bab;
  --primary-soft: #e8f4fd;
  --on-primary: #ffffff;
  --accent-green: #1aae39;
  --green-deep: #14832c;
  --green-soft: #eaf6ec;
  --accent-orange: #dd5b00;
  --orange-soft: #fdf0e7;
  --danger: #e03e3e;
  --danger-soft: #fdeeee;
  --radius-xs: 4px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-soft: rgba(0, 0, 0, .01) 0 .175px 1.041px,
    rgba(0, 0, 0, .02) 0 .8px 2.925px,
    rgba(0, 0, 0, .027) 0 2.025px 7.847px,
    rgba(0, 0, 0, .04) 0 4px 18px;
  --shadow-card: var(--shadow-soft);
  --shadow-hover: rgba(0, 0, 0, .02) 0 1px 3.6px,
    rgba(0, 0, 0, .03) 0 4px 10px,
    rgba(0, 0, 0, .04) 0 8px 24px;
  --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, .14);
  --z-header: 20;
  --z-sheet: 50;
  --z-toast: 70;
  font-family: Inter, -apple-system, "Segoe UI", "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-feature-settings: "lnum";
  font-synthesis: none;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

button, select { cursor: pointer; }

button { touch-action: manipulation; }

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(0, 117, 222, .4);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: var(--on-primary);
  background: var(--ink);
  border-radius: var(--radius-md);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

/* 顶栏：Notion 白底导航 + 发丝线，取代旧的深色顶栏。 */
.app-header {
  position: sticky;
  z-index: var(--z-header);
  top: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--hairline);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(100%, 1440px);
  min-height: 76px;
  margin: 0 auto;
  padding: 12px clamp(16px, 3vw, 36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-block { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #d3e9f9;
  border-radius: var(--radius-md);
}

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

.eyebrow,
.section-kicker {
  margin: 0 0 1px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .125px;
  text-transform: uppercase;
}

.brand-block .eyebrow { color: var(--primary); }

.brand-block h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(18px, 2.5vw, 22px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.125px;
}

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

.header-navigation {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-history-link {
  min-height: 44px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  touch-action: manipulation;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.header-history-link svg { width: 19px; height: 19px; flex: 0 0 auto; }
.header-history-link:hover { background: var(--canvas); border-color: var(--hairline-strong); }
.header-history-link:active { background: #eeedec; }

.page-shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px);
}

.control-panel {
  padding: clamp(18px, 3vw, 28px);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.control-heading,
.orders-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.control-heading h2,
.orders-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.625px;
}

.order-count {
  padding: 4px 10px;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid #d3e9f9;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.control-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field-control { min-width: 0; }

.field-label {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-secondary);
  font-size: 14px;
  font-weight: 600;
}

.field-label svg,
.icon-text-button svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

/* 输入框：Notion text-input——白底、4px 小圆角、发丝边。 */
.field-control input,
.field-control select {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #dcdcdc;
  border-radius: var(--radius-xs);
  font-size: 16px;
  font-weight: 500;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.field-control input:hover,
.field-control select:hover { border-color: var(--ink-faint); }

.field-control input:disabled,
.field-control select:disabled {
  cursor: not-allowed;
  opacity: .62;
}

.field-control input:focus,
.field-control select:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: var(--shadow-soft);
  outline: none;
}

.select-wrap { position: relative; display: block; }

.select-wrap select {
  padding-right: 48px;
  appearance: none;
}

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

.control-error {
  min-height: 0;
  margin-bottom: 0;
}

.orders-section { margin-top: clamp(26px, 4vw, 42px); }

.orders-heading { margin-bottom: 16px; }

.icon-text-button {
  min-height: 44px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.icon-text-button:hover { background: var(--canvas); border-color: var(--hairline-strong); }

.icon-text-button:disabled {
  cursor: wait;
  opacity: .56;
}

.loading-state {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
}

.loading-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-secondary);
}

.loading-heading > div { min-width: 0; }
.loading-heading strong { display: block; color: var(--ink); font-size: 15px; }
.loading-heading span:last-child { display: block; margin-top: 1px; font-size: 13px; }

.loading-spinner,
.button-spinner {
  flex: 0 0 auto;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 750ms linear infinite;
}

.loading-spinner { width: 30px; height: 30px; }

.loading-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.skeleton-card {
  min-height: 278px;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.skeleton-card > * {
  display: block;
  margin: 0;
  background: linear-gradient(90deg, #efeeed 25%, #e6e5e4 45%, #efeeed 65%);
  background-size: 240% 100%;
  border-radius: var(--radius-xs);
  animation: skeleton-sweep 1.3s ease-in-out infinite;
}

.skeleton-card i { height: 20px; }
.skeleton-card i:first-child { width: 72%; }
.skeleton-card i:nth-child(2) { width: 58%; justify-self: end; }
.skeleton-card b { height: 72px; }
.skeleton-card em { grid-column: 1 / -1; height: 104px; }

.empty-state {
  min-height: 330px;
  padding: 48px 24px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  background: var(--canvas);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-lg);
}

.empty-state[hidden],
.card-grid[hidden] {
  display: none;
}

.empty-illustration {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-lg);
}

.empty-illustration svg { width: 46px; height: 46px; }
.empty-state h3 { margin: 17px 0 4px; color: var(--ink); font-size: 20px; font-weight: 700; }
.empty-state p { margin: 0; color: var(--ink-muted); }

.empty-action {
  min-height: 46px;
  margin-top: 18px;
  padding: 10px 18px;
  color: var(--on-primary);
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 999px;
  font-weight: 500;
}

.empty-action:hover { background: var(--primary-active); border-color: var(--primary-active); }

.batch-toolbar {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
}

.batch-toolbar-head,
.batch-selection-bar,
.allocation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.batch-toolbar-head h3,
.allocation-heading h3 { margin: 0; font-size: 17px; }

.batch-cancel {
  min-height: 44px;
  padding: 8px 12px;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
}

.batch-cancel:hover { color: var(--ink); background: var(--canvas); }

.batch-mode-buttons {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.batch-mode-button {
  min-height: 48px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  font-weight: 600;
}

.batch-mode-button:hover { background: var(--canvas); }
.batch-mode-button[aria-pressed="true"] { color: var(--primary-active); background: var(--primary-soft); border-color: #aad6f5; }
.batch-mode-button.report[aria-pressed="true"] { color: var(--green-deep); background: var(--green-soft); border-color: #bde3c5; }

.batch-selection-bar {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--hairline);
}

.select-all-control {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-weight: 600;
}

.select-all-control input,
.batch-card-selector input { width: 20px; height: 20px; accent-color: var(--primary); }
.batch-selection-summary { margin-left: auto; color: var(--ink-muted); font-size: 13px; }

.batch-open-button {
  min-height: 46px;
  padding: 9px 16px;
  color: var(--on-primary);
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 999px;
  font-weight: 600;
}

.batch-open-button:disabled { color: var(--ink-faint); background: var(--canvas); border-color: var(--hairline); cursor: not-allowed; }
.batch-eligibility-hint { margin: 10px 0 0; color: var(--ink-muted); font-size: 13px; }

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

/* 工单卡片：白色表面 + 发丝线 + 12px 圆角，静置无阴影、悬停轻浮起。 */
.order-card {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.order-card:hover {
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-hover);
}

.order-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0, 117, 222, .12); }
.order-card.is-batch-mode .card-actions { display: none; }

.batch-card-state {
  min-height: 50px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  background: #fbfbfa;
  border-top: 1px solid var(--hairline);
}

.batch-card-selector {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
}

.batch-ineligible { color: var(--ink-muted); font-size: 13px; }

.card-main { padding: 18px; }

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

.card-head > div:first-child { flex: 1 1 auto; min-width: 0; }

.work-order-label {
  display: block;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 500;
}

.work-order-no {
  margin: 3px 0 0;
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: clamp(18px, 2.3vw, 21px);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.25px;
  overflow-wrap: anywhere;
}

.card-badges {
  flex: 0 0 auto;
  max-width: 52%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.group-badge {
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  padding: 5px 9px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  color: var(--ink-secondary);
  background: var(--surface-warm);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
  text-align: right;
}

.group-badge-label {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
}

.group-badge-value {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.style-badge {
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #d3e9f9;
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
  text-align: right;
}

.style-badge-label {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
}

.style-badge-value {
  margin-top: 2px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: clamp(16px, 1.7vw, 18px);
  font-weight: 700;
  line-height: 1.2;
}

.metric-grid {
  margin: 17px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.metric {
  min-width: 0;
  padding: 11px 12px;
}

.metric:nth-child(odd) { border-right: 1px solid var(--hairline); }
.metric:nth-child(n+3) { border-top: 1px solid var(--hairline); }

.metric dt {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 500;
}

.metric dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.metric.remaining dd { color: var(--accent-orange); }
.metric.today-output dd { color: var(--green-deep); }

.target-block {
  margin-top: 14px;
  padding: 13px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.target-block.is-empty {
  color: var(--ink-muted);
  background: var(--surface);
  border-color: var(--hairline);
}

.target-head,
.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.target-label {
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
}

.target-value {
  color: var(--primary);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.target-block.is-empty .target-value { color: var(--ink-muted); font-size: 14px; }

.progress-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  background: #e9e8e7;
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
  transition: transform 260ms ease;
  transform-origin: left;
}

.progress-fill.is-over { background: var(--accent-green); }

.progress-meta {
  margin-top: 7px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 500;
}

.over-badge {
  padding: 2px 6px;
  color: var(--green-deep);
  background: var(--green-soft);
  border-radius: 999px;
  font-weight: 600;
}

.selected-date-state {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-muted);
  font-size: 12px;
}

.selected-date-state svg { width: 17px; height: 17px; }
.selected-date-state.has-target { color: var(--green-deep); }
.selected-date-state.no-target { color: var(--accent-orange); }

.card-actions {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: #fbfbfa;
  border-top: 1px solid var(--hairline);
}

/* 卡片操作：目标为工具按钮（白底 8px），日报为唯一蓝色主操作。 */
.action-button {
  min-height: 50px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.action-button svg { width: 20px; height: 20px; flex: 0 0 auto; }

.target-button {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
}

.target-button:hover:not(:disabled) { background: var(--canvas); border-color: var(--hairline-strong); }

.report-button {
  color: var(--on-primary);
  background: var(--primary);
  border: 1px solid var(--primary);
}

.report-button:hover:not(:disabled) { background: var(--primary-active); border-color: var(--primary-active); }

.action-button:active:not(:disabled) { transform: scale(.98); }

.action-button:disabled {
  color: var(--ink-faint);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  cursor: not-allowed;
  opacity: .82;
}

.sheet-layer {
  position: fixed;
  z-index: var(--z-sheet);
  inset: 0;
  display: grid;
  place-items: end center;
}

.sheet-layer[hidden] { display: none; }

.sheet-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(15, 15, 15, .45);
  border: 0;
  backdrop-filter: blur(3px);
  animation: fade-in 180ms ease-out both;
}

.quantity-sheet {
  position: relative;
  width: min(100%, 620px);
  max-height: min(92dvh, 780px);
  padding: 12px clamp(18px, 4vw, 30px) calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-sheet);
  animation: sheet-in 240ms cubic-bezier(.2,.8,.2,1) both;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: 0 auto 15px;
  background: var(--hairline-strong);
  border-radius: 999px;
}

.sheet-head { display: flex; align-items: center; gap: 12px; }

.sheet-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-md);
}

.sheet-icon.report { color: var(--green-deep); background: var(--green-soft); }
.sheet-icon svg { width: 25px; height: 25px; }

.sheet-title-block { flex: 1; min-width: 0; }
.sheet-title-block h2 { margin: 0; font-size: 23px; font-weight: 700; line-height: 1.2; letter-spacing: -.25px; }

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--ink-secondary);
  background: rgba(0, 0, 0, .05);
  border: 0;
  border-radius: 50%;
}

.icon-button:hover { background: rgba(0, 0, 0, .09); }
.icon-button svg { width: 22px; height: 22px; }

.sheet-context {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.sheet-context > div { min-width: 0; padding: 11px 13px; }
.sheet-context > div:nth-child(odd) { border-right: 1px solid var(--hairline); }
.sheet-context > div:nth-child(n+3) { border-top: 1px solid var(--hairline); }
.sheet-context span { display: block; color: var(--ink-muted); font-size: 12px; }
.sheet-context strong { display: block; margin-top: 2px; color: var(--ink); overflow-wrap: anywhere; font-size: 14px; }

.sheet-context > .sheet-target-context {
  grid-column: 1 / -1;
  padding: 12px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--primary-soft);
  border-top: 1px solid #d3e9f9;
  border-right: 0;
}

.sheet-context > .sheet-target-context strong {
  margin: 0;
  color: var(--primary);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.sheet-target-context[hidden] { display: none; }

.quantity-field { margin-top: 22px; }
.quantity-field > label { display: block; margin-bottom: 8px; font-weight: 600; }

.quantity-input-wrap {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  overflow: hidden;
  border: 1px solid #dcdcdc;
  border-radius: var(--radius-xs);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.quantity-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-soft);
}

.quantity-input-wrap button {
  min-height: 58px;
  display: grid;
  place-items: center;
  color: var(--ink-secondary);
  background: var(--canvas);
  border: 0;
}

.quantity-input-wrap button:hover { background: #eeedec; }
.quantity-input-wrap button svg { width: 23px; height: 23px; }

.quantity-input-wrap input {
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-right: 1px solid var(--hairline);
  border-left: 1px solid var(--hairline);
  outline: 0;
  font-size: 27px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}

.quantity-input-wrap input::-webkit-inner-spin-button { appearance: none; }

.quantity-meta {
  min-height: 38px;
  margin-top: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-muted);
  font-size: 12px;
}

.quantity-meta button {
  min-height: 44px;
  padding: 5px 8px;
  color: var(--primary);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}

.quantity-meta button:hover { background: var(--primary-soft); }

.field-error {
  min-height: 22px;
  margin: 3px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
}

.sheet-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(100px, .7fr) minmax(170px, 1.3fr);
  gap: 10px;
}

/* 次要=工具按钮（8px），主操作=胶囊（pill），Notion 的对比规则。 */
.secondary-button,
.primary-button {
  min-height: 54px;
  padding: 12px 16px;
  font-weight: 500;
}

.secondary-button {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.secondary-button:hover { background: var(--canvas); }

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--on-primary);
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 999px;
}

.primary-button.report { background: var(--primary); border-color: var(--primary); }
.primary-button:hover { background: var(--primary-active); border-color: var(--primary-active); }
.primary-button:disabled { cursor: wait; opacity: .64; }

.button-spinner {
  width: 19px;
  height: 19px;
  border-width: 2px;
  border-color: rgba(255,255,255,.35);
  border-top-color: #fff;
}

.submit-status {
  min-height: 42px;
  margin: 2px 0 0;
  padding: 9px 12px;
  color: var(--primary-active);
  background: var(--primary-soft);
  border: 1px solid #d3e9f9;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.batch-sheet { width: min(100%, 720px); }

.batch-summary-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.batch-summary-grid > div { min-width: 0; padding: 11px 13px; }
.batch-summary-grid > div + div { border-left: 1px solid var(--hairline); }
.batch-summary-grid span { display: block; color: var(--ink-muted); font-size: 12px; }
.batch-summary-grid strong { display: block; margin-top: 2px; overflow-wrap: anywhere; font-size: 15px; }

.batch-total-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.batch-total-row input {
  min-width: 0;
  min-height: 54px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  font-size: 22px;
  font-weight: 700;
}
.batch-total-row button {
  min-height: 54px;
  padding: 10px 14px;
  color: var(--primary-active);
  background: var(--primary-soft);
  border: 1px solid #d3e9f9;
  border-radius: var(--radius-md);
  font-weight: 600;
}
.batch-quantity-hint { margin: 8px 0 0; color: var(--ink-muted); font-size: 12px; }

.allocation-block { margin-top: 12px; }
.allocation-heading span { color: var(--ink-muted); font-size: 12px; }
.allocation-list {
  max-height: 230px;
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}
.allocation-list li {
  min-height: 48px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}
.allocation-list li + li { border-top: 1px solid var(--hairline); }
.allocation-index { color: var(--ink-muted); font-size: 12px; }
.allocation-order { min-width: 0; overflow-wrap: anywhere; }
.allocation-order small { display: block; color: var(--ink-muted); }
.allocation-quantity { color: var(--primary-active); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.allocation-empty { display: block !important; color: var(--ink-muted); text-align: center; }

.interface-notice {
  margin: 13px 0 0;
  padding: 10px 12px;
  color: var(--ink-secondary);
  background: var(--orange-soft);
  border: 1px solid #f2d4bf;
  border-radius: var(--radius-md);
  font-size: 13px;
}
.batch-sheet .primary-button:disabled { cursor: not-allowed; opacity: .58; }

/* Toast：白卡 + 多层浅阴影，图标负责状态色。 */
.toast {
  position: fixed;
  z-index: var(--z-toast);
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  min-height: 50px;
  width: min(calc(100% - 32px), 420px);
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hover);
  font-weight: 500;
  text-align: center;
  animation: toast-in 200ms ease-out both;
}

.toast[hidden] { display: none; }
.toast svg { width: 21px; height: 21px; color: var(--accent-green); flex: 0 0 auto; }
.toast[data-type="error"] svg { color: var(--danger); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes skeleton-sweep { to { background-position: -120% 0; } }
@keyframes sheet-in { from { opacity: .6; transform: translateY(42px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

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

@media (max-width: 700px) {
  .header-inner {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "brand" "nav";
    gap: 8px 12px;
  }
  .brand-block { grid-area: brand; }
  .brand-mark { width: 40px; height: 40px; }
  .header-actions { display: contents; }
  .header-navigation {
    grid-area: nav;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .header-history-link { min-width: 0; padding: 8px 6px; }
  .page-shell { padding: 16px; }
  .control-panel { padding: 17px; border-radius: var(--radius-lg); }
  .control-heading { align-items: flex-start; }
  .control-grid { grid-template-columns: 1fr; gap: 13px; }
  .orders-section { margin-top: 28px; }
  .card-grid,
  .loading-grid { grid-template-columns: 1fr; gap: 14px; }
  .skeleton-card:nth-child(n+2) { display: none; }
  .order-card:hover { box-shadow: none; }
  .quantity-sheet { width: 100%; }
  .batch-selection-bar { align-items: stretch; flex-wrap: wrap; }
  .batch-selection-summary { margin-left: 0; align-self: center; }
  .batch-open-button { margin-left: auto; }
}

@media (max-width: 430px) {
  .header-history-link {
    padding-inline: 3px;
    gap: 4px;
    font-size: 12px;
    white-space: nowrap;
  }
  .header-history-link svg { width: 17px; height: 17px; }
  .control-heading h2, .orders-heading h2 { font-size: 20px; }
  .order-count { font-size: 12px; }
  .card-main { padding: 16px; }
  .sheet-context { grid-template-columns: 1fr; }
  .sheet-context > div:nth-child(odd) { border-right: 0; }
  .sheet-context > div + div { border-top: 1px solid var(--hairline); }
  .quantity-meta { align-items: flex-start; }
  .sheet-actions { grid-template-columns: .78fr 1.22fr; }
  .batch-mode-buttons { grid-template-columns: 1fr; }
  .batch-summary-grid { grid-template-columns: 1fr; }
  .batch-summary-grid > div + div { border-top: 1px solid var(--hairline); border-left: 0; }
  .batch-total-row { grid-template-columns: 1fr; }
  .batch-total-row button { min-height: 46px; }
  .batch-open-button { width: 100%; margin-left: 0; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .quantity-sheet {
    max-height: 100dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .sheet-context { margin-top: 12px; }
  .quantity-field { margin-top: 14px; }
}

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

/* HOME unified process switch */
.process-toolbar { display:flex; align-items:center; gap:16px; margin:16px 0; flex-wrap:wrap; }
.process-toggle { display:inline-flex; align-items:center; gap:10px; padding:10px 16px; border:1px solid #d5d9df; border-radius:12px; background:white; color:#28332e; cursor:pointer; }
.process-toggle-track { width:38px; height:22px; border-radius:20px; background:#a0a7ad; position:relative; }
.process-toggle-track::after { content:""; position:absolute; width:16px; height:16px; top:3px; left:3px; background:white; border-radius:50%; }
.process-toggle[aria-checked="true"] .process-toggle-track { background:#267b53; }
.process-toggle[aria-checked="true"] .process-toggle-track::after { left:19px; }
[hidden] { display:none !important; }

.card-actions.is-screen-print { grid-template-columns: minmax(0, 1fr); }
