:root {
  color-scheme: light;
  --ui-primary: #17624a;
  --ui-primary-strong: #0f4f3b;
  --ui-primary-soft: #e8f4ee;
  --ui-primary-line: #afd4c3;
  --ui-bg: #f5f8f6;
  --ui-card: #ffffff;
  --ui-text: #183129;
  --ui-muted: #60736c;
  --ui-line: #d8e3de;
  --ui-warning: #9a6417;
  --ui-warning-soft: #fff4dc;
  --ui-danger: #b5433d;
  --ui-danger-soft: #fae9e7;
  --ui-shadow: 0 10px 28px rgba(22, 69, 54, 0.09);
  --ui-radius: 16px;
}

html { background: var(--ui-bg); }
body {
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button,
a { touch-action: manipulation; }

button:not(:disabled),
[role="button"],
summary { cursor: pointer; }

/* 全系统只保留三层操作：绿色主动作、白色次动作、红色异常动作。 */
.primary-button,
.save-button,
.start-button,
.next-flow-fab {
  min-height: 48px;
  border: 1px solid var(--ui-primary) !important;
  border-radius: 13px;
  background: var(--ui-primary) !important;
  color: #fff !important;
  font-weight: 850;
  box-shadow: 0 7px 16px rgba(23, 98, 74, 0.18);
}

.primary-button:hover,
.save-button:hover,
.start-button:hover,
.next-flow-fab:hover { background: var(--ui-primary-strong) !important; }

.secondary-button,
.link-button,
.ghost-button,
.light-button,
.flow-button,
.workflow-home,
.workflow-scan,
.station-nav a,
.warehouse-tab {
  min-height: 48px;
  border-color: var(--ui-line) !important;
  border-radius: 13px;
  background: var(--ui-card) !important;
  color: var(--ui-primary-strong) !important;
  font-weight: 800;
  box-shadow: none;
}

.danger-button,
.reset-button {
  min-height: 48px;
  border-color: #e7b7b2 !important;
  border-radius: 13px;
  background: var(--ui-danger-soft) !important;
  color: var(--ui-danger) !important;
  box-shadow: none;
}

.small-button { min-height: 44px; }
.text-button { color: var(--ui-primary); }
.topbar-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.more-tools { margin-left: auto; }
.more-tools summary { color: var(--ui-primary); font-weight: 800; white-space: nowrap; }
.more-tools[open] .scope-actions { margin-top: 8px; }

button:active,
.primary-button:active,
.secondary-button:active,
.link-button:active { transform: translateY(1px); }

button:disabled,
.primary-button:disabled,
.save-button:disabled,
.start-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

[aria-busy="true"] { pointer-events: none; opacity: 0.62; }

:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 3px solid rgba(23, 98, 74, 0.28);
  outline-offset: 3px;
}

/* 普通说明用浅绿；黄色只留给真正待办，红色只留给异常。 */
.notice,
.scope-banner {
  border-color: var(--ui-primary-line) !important;
  background: var(--ui-primary-soft) !important;
  color: #345d4f !important;
}

.notice strong,
.scope-banner strong { color: var(--ui-primary-strong) !important; }

.status-note,
.priority-card.has-work,
.attention-card {
  border-color: #e5c47f !important;
  background: var(--ui-warning-soft) !important;
  color: #68470f;
}

.error-box,
.toast.error,
.risk-badge.danger,
.board-metric.bad { background: var(--ui-danger-soft); color: var(--ui-danger); }

.panel,
.inspection-panel,
.queue-panel,
.identity-card,
.metric-card,
.order-card,
.nav-card {
  border-color: var(--ui-line);
  background: var(--ui-card);
  box-shadow: var(--ui-shadow);
}

.brand-mark,
.auth-brand-mark { background: var(--ui-primary) !important; }

.eyebrow,
.flow-header h1,
.quality-header h1,
.station-header h1,
.nav-card strong,
.summary-item strong,
.count-pill { color: var(--ui-primary-strong); }

.connection { box-shadow: none; border: 1px solid var(--ui-line); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.workflow-nav {
  position: sticky;
  z-index: 15;
  top: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 0;
  background: linear-gradient(var(--ui-bg) 72%, rgba(245, 248, 246, 0));
}

.workflow-nav a,
.station-nav a,
.warehouse-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
}

.warehouse-tabs {
  scrollbar-width: thin;
  border-color: var(--ui-line);
  background: rgba(255, 255, 255, 0.88);
}

.warehouse-tab.active {
  border-color: var(--ui-primary) !important;
  background: var(--ui-primary) !important;
  color: #fff !important;
}

.field input,
.field select,
.field textarea,
.form-grid input,
.form-grid select,
.full-label textarea,
.inline-add input,
.batch-form label,
.picker-button,
.pattern-row input {
  border-color: var(--ui-line);
  background: #fbfdfc;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.form-grid input:focus,
.form-grid select:focus,
.full-label textarea:focus,
.inline-add input:focus,
.picker-button:focus-visible,
.pattern-row input:focus {
  border-color: var(--ui-primary);
  box-shadow: 0 0 0 4px rgba(23, 98, 74, 0.11);
}

.nav-card,
.priority-card,
.task-card,
.order-picker,
.pattern-progress-card { transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease; }

.nav-card:hover,
.priority-card:hover,
.order-picker:hover,
.pattern-progress-card:hover {
  border-color: var(--ui-primary-line);
  box-shadow: 0 12px 26px rgba(23, 98, 74, 0.12);
  transform: translateY(-1px);
}

.nav-card { position: relative; padding-right: 48px; }
.nav-card::after {
  content: "›";
  position: absolute;
  top: 50%;
  right: 20px;
  color: var(--ui-primary);
  font-size: 30px;
  font-weight: 700;
  transform: translateY(-52%);
}

.priority-panel {
  border-color: var(--ui-primary) !important;
  background: linear-gradient(145deg, #fff, #f0f8f4);
}

.priority-empty,
.success-box,
.summary-item { background: var(--ui-primary-soft); }

.target-task {
  border: 2px solid var(--ui-primary) !important;
  background: var(--ui-primary-soft) !important;
  box-shadow: 0 0 0 5px rgba(23, 98, 74, 0.10) !important;
}

.scan-guide-step > b,
.toast { background: var(--ui-primary); }

.scan-result { border: 1px solid var(--ui-line); background: #f9fbfa; }

@media (max-width: 720px) {
  .flow-app,
  .quality-app,
  .cutting-app { padding-left: 12px; padding-right: 12px; }

  .workflow-nav { justify-content: stretch; }
  .workflow-nav a { flex: 1 1 0; min-width: 0; padding-inline: 8px; }

  .flow-header,
  .quality-header,
  .station-header {
    align-items: flex-start;
    gap: 10px;
  }

  .flow-header { flex-wrap: wrap; }
  .station-meta { flex-wrap: wrap; }
  .header-actions { flex-wrap: wrap; }

  .form-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .form-actions > *,
  .inspection-actions > *,
  .task-actions > * { min-height: 52px; }

  .form-actions > * { flex: 1 1 100%; }

  .nav-card {
    min-height: 112px;
    padding: 18px 46px 18px 18px;
  }

  .notice { line-height: 1.55; }
}

@media (max-width: 600px) {
  .quality-header,
  .station-header { display: grid; grid-template-columns: 1fr; }

  .header-meta,
  .station-meta { justify-content: space-between; }

  .quality-app .batch-form { grid-template-columns: 1fr; }
  .quality-app .balance-line { flex-wrap: wrap; }
  .quality-app .balance-line #balanceStatus { width: 100%; margin-left: 0; }
}

@media (max-width: 430px) {
  .flow-header { display: grid; grid-template-columns: 1fr; }
  .flow-header .connection { justify-self: start; }
  .header-actions { width: 100%; justify-content: space-between; }
  .summary-strip.three-items { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media print {
  .workflow-nav { display: none !important; }
}

/* Keep the confirmation within reach without moving the task under the user. */
.form-actions, .inspection-actions, .task-action-bar, .scan-actions:has(button.primary-button) {
  position: sticky;
  bottom: 0;
  z-index: 8;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--ui-line);
}
html { scroll-padding-bottom: 110px; }
.field input, .field select, .field textarea { scroll-margin-bottom: 110px; }
summary.section-heading { min-height: 48px; cursor: pointer; list-style: none; }
summary.section-heading::-webkit-details-marker { display: none; }
summary.section-heading::after { content: "展开 ＋"; font-size: 13px; color: var(--ui-primary); white-space: nowrap; }
details[open] > summary.section-heading::after { content: "收起 −"; }
.local-sticky-actions { position: sticky; bottom: 0; z-index: 7; padding: 12px 0; background: #fff; }
.quick-scan-dialog { width: min(92vw, 480px); max-height: 88dvh; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--ui-line); border-radius: 18px; padding: 20px; color: var(--ui-ink); }
.quick-scan-dialog::backdrop { background: rgba(15, 35, 29, .45); }
.quick-scan-result { padding: 14px; margin: 16px 0; background: var(--ui-primary-soft); border-radius: 12px; }
.quick-scan-actions { display: grid; gap: 12px; }
.quick-scan-actions > * { min-height: 48px; text-align: center; }
.live-scan-frame { width: 100%; max-width: 480px; aspect-ratio: 4 / 3; position: relative; overflow: hidden; border-radius: 14px; background: #10251e; margin: 14px auto; }
.live-scan-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.live-scan-guide { position: absolute; width: 62%; aspect-ratio: 1; max-height: 88%; border: 2px solid #fff; border-radius: 12px; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: .55; pointer-events: none; }
.live-scan-frame[data-active="true"] .live-scan-guide { border-color: #a1efb9; opacity: 1; }
.quick-scan-dialog .scan-manual-details { margin-top: 18px; }
.quick-scan-dialog .scan-manual-form { display: grid; gap: 12px; margin-top: 12px; }
.quick-scan-result { min-height: 88px; }
.task-operation { display: grid; gap: 12px; margin-top: 14px; }
.task-operation > button, .task-operation > a, .task-operation > .primary-button, .task-operation > .secondary-button { width: 100%; min-height: 52px; padding: 14px 16px; text-align: center; white-space: normal; }
@media (max-width: 480px) {
  .quick-scan-dialog { padding: 16px; }
  .quick-scan-dialog .live-scan-frame { max-height: 34dvh; }
  .quick-scan-dialog .quick-scan-result { margin-block: 12px; padding: 12px; }
}
@media print {
  .form-actions, .inspection-actions, .task-action-bar, .scan-actions { position: static; }
}
/* Orders are the first level; existing task controls remain inside each group. */
.order-record-group { grid-column: 1 / -1; width: 100%; border: 1px solid #d7e5df; border-radius: 14px; background: #fff; padding: 12px; }
.order-record-group > summary { cursor: pointer; padding: 14px 6px; min-height: 48px; font-weight: 700; color: #125340; }
.order-record-group > article, .order-record-group > .recent-item { margin: 10px 0; }
.daily-table-scroll { overflow-x:auto; width:100%; }
.daily-production-table { width:100%; border-collapse:collapse; font-size:15px; }
.daily-production-table caption { text-align:left; font-weight:700; padding:12px 0; }
.daily-production-table th,.daily-production-table td { padding:12px 8px; border-bottom:1px solid #dce8e3; text-align:left; }
.daily-production-table th { background:#edf6f1; color:#174f3d; white-space:nowrap; }
.daily-production-table td { overflow-wrap:anywhere; }
.daily-production-table small { display:block; font-size:12px; color:#596d65; white-space:nowrap; }
[data-quality-team] { margin:20px 0; padding:20px; border:1px solid #d7e5df; border-radius:16px; background:#fff; }
[data-quality-team] label { display:block; margin:12px 0; color:#174f3d; font-weight:600; }
[data-quality-team] input:not([type=checkbox]), [data-quality-team] select { display:block; width:100%; min-height:48px; padding:10px; border:1px solid #c6d8cf; border-radius:10px; font:inherit; box-sizing:border-box; }
[data-quality-team] .task-card { border:1px solid #d7e5df; border-radius:12px; padding:16px; margin:12px 0; }
[data-quality-team] button { min-height:48px; margin:6px 4px 6px 0; }
[data-team-notice] { color:#174f3d; background:#edf6f1; padding:12px; border-radius:10px; }
