:root {
  --bg: #f5f9fd;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --line: #dce7f2;
  --line-strong: #b8d5ee;
  --text: #263648;
  --muted: #718295;
  --blue: #1688dc;
  --blue-2: #22a8e8;
  --blue-soft: #e8f5ff;
  --green: #39bd7f;
  --green-soft: #e8f8f0;
  --orange: #f2a10d;
  --orange-soft: #fff4dc;
  --red: #e94b5b;
  --red-soft: #fff0f2;
  --shadow: 0 10px 28px rgba(31, 84, 132, 0.1);
  --radius: 8px;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid rgba(22, 136, 220, 0.45);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 1001;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  text-decoration: none;
  transform: translateY(-160%);
}

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

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(145deg, #0f7bd3, #28b8ea);
  box-shadow: 0 8px 18px rgba(22, 136, 220, 0.22);
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

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

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  padding-right: 3px;
}

.nav button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #4a5d71;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  text-align: left;
  font-size: 14px;
  transition: 0.18s ease;
}

.nav button svg,
.icon-btn svg,
.mini-ocr svg,
.drop-zone svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.nav button.active,
.nav button:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.nav .group {
  margin-top: 9px;
  color: #8ba0b2;
  font-size: 12px;
  padding: 0 10px;
}

.collapse-btn {
  margin-top: auto;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
}

.main {
  min-width: 0;
  padding: 20px 24px 32px;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

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

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn,
.ghost-btn,
.primary-btn,
.link-btn {
  border-radius: 6px;
  border: 1px solid var(--line);
  height: 36px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

/* 表格操作列按钮组：统一间距 */
.td-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.icon-btn {
  width: 38px;
  padding: 0;
  color: var(--blue);
}

.primary-btn {
  border-color: #0878cc;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 5px 12px rgba(22, 136, 220, 0.22);
}

.primary-btn.small {
  height: 32px;
  font-size: 13px;
}

.ghost-btn:hover,
.link-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.link-btn {
  height: 30px;
  padding: 0 10px;
  color: var(--blue);
  border-color: transparent;
  background: var(--blue-soft);
  font-size: 13px;
}

.user-chip {
  min-width: 116px;
  height: 40px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #eef7ff;
  border: 1px solid #cfebff;
  color: var(--text);
  text-align: left;
}

.user-chip span,
.user-chip small {
  display: block;
}

.user-chip span {
  font-weight: 700;
  font-size: 13px;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.kpi-card,
.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 16px;
  display: flex;
  gap: 12px;
  min-height: 104px;
  min-width: 0;
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  flex: 0 0 auto;
}

.kpi-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
  display: block;
  line-height: 1.25;
  white-space: nowrap;
}

.kpi-card strong {
  display: block;
  margin-top: 7px;
  font-size: 23px;
  line-height: 1;
}

.kpi-card small {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--green);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.45fr 0.8fr 0.9fr;
  gap: 16px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

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

.panel.tall {
  grid-row: span 2;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend .blue {
  background: var(--blue-2);
}

.legend .green {
  background: var(--green);
}

.line-chart {
  width: 100%;
  height: 260px;
}

.grid-lines path {
  stroke: #e9f0f7;
  stroke-width: 1;
}

.area {
  opacity: 0.14;
}

.area.in {
  fill: var(--blue-2);
}

.area.out {
  fill: var(--green);
}

.series {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series.in {
  stroke: var(--blue-2);
}

.series.out {
  stroke: var(--green);
}

.axis text {
  fill: #7b8da0;
  font-size: 12px;
}

.donut-wrap {
  min-height: 230px;
  display: grid;
  place-items: center;
  gap: 16px;
}

.donut {
  width: 142px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--blue-2) 0 41.5%, var(--green) 41.5% 66.2%, #7c65e8 66.2% 88.8%, var(--orange) 88.8% 100%);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut-list {
  width: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
}

.donut-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.donut-list b {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.donut-list span {
  margin-left: auto;
  color: var(--text);
  font-weight: 700;
}

.c1 { background: var(--blue-2); }
.c2 { background: var(--green); }
.c3 { background: #7c65e8; }
.c4 { background: var(--orange); }

.warning-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.warning-list div {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.warning-list span {
  color: var(--muted);
  font-size: 13px;
}

.warning-list strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  background: #f8fbff;
  color: #52677d;
  font-weight: 700;
}

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

.tag {
  display: inline-flex;
  height: 24px;
  align-items: center;
  border-radius: 5px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.tag.green {
  color: #168f5b;
  background: var(--green-soft);
}

.tag.orange {
  color: #ad7005;
  background: var(--orange-soft);
}

.tag.red {
  color: #c73343;
  background: var(--red-soft);
}

.tag.blue {
  color: #0c6fb7;
  background: var(--blue-soft);
}

.mini-ocr {
  display: grid;
  gap: 12px;
}

.upload-card {
  height: 92px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--blue);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background: #f6fbff;
}

.upload-card svg {
  width: 28px;
  height: 28px;
}

.review-lines {
  display: grid;
  gap: 10px;
}

label {
  color: #44586c;
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  padding: 0 10px;
  color: var(--text);
  outline: 0;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(34, 168, 232, 0.12);
}

input.autofilled,
select.autofilled {
  border-color: #70c8f1;
  background: #f3fbff;
  box-shadow: 0 0 0 3px rgba(34, 168, 232, 0.1);
}

.review-lines input,
.form-grid input,
.form-grid select {
  margin-top: 6px;
}

.ocr-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section-line {
  height: 34px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.section-line::before,
.section-line::after {
  content: "";
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue));
}

.section-line::after {
  background: linear-gradient(90deg, var(--blue), transparent);
}

.section-line span {
  background: var(--blue);
  border-radius: 5px;
  padding: 5px 14px;
  font-weight: 700;
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.primary-btn:not(.small) {
  min-width: 96px;
  margin-top: 16px;
}

.ocr-actions .primary-btn {
  margin-top: 0;
}

.form-footer {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
  align-items: end;
}

.inline-setting {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.inline-setting input {
  width: 86px;
}

/* ─── OCR 单据类型分段控件（品牌蓝高亮，弱化多色，融入板块） ─── */
.doc-type-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.doc-type-switch button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 18px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.doc-type-switch button:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.doc-type-switch button.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 4px 10px rgba(22, 136, 220, 0.25);
}

.doc-type-switch .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--line-strong);
  transition: background 0.15s ease;
}

.doc-type-switch button.active .dot {
  background: #fff;
}

.drop-zone {
  min-height: 176px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  background: #f7fbff;
  cursor: pointer;
  padding: 18px;
}

.drop-zone input {
  display: none;
}

.drop-zone svg {
  width: 38px;
  height: 38px;
  color: var(--blue);
}

.drop-zone strong {
  font-size: 15px;
}

.drop-zone span {
  max-width: 360px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.preview {
  margin-top: 14px;
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
  overflow: hidden;
  color: var(--muted);
}

.preview img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
}

/* 上传区 + 拍照按钮 */
.drop-zone-wrap {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.drop-zone-wrap .drop-zone {
  flex: 1;
}

.camera-btn {
  width: 90px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.camera-btn:hover {
  border-color: var(--blue);
  background: #f0f8ff;
}

.camera-btn svg {
  width: 28px;
  height: 28px;
}

/* 摄像头拍摄浮层 */
.camera-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: grid;
  place-items: center;
  z-index: 110;
}

.camera-overlay[hidden] {
  display: none;
}

.camera-dialog {
  width: min(720px, calc(100vw - 32px));
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.camera-dialog video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  display: block;
}

.camera-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: #111;
}

/* 单据类型歧义确认 */
.modal.small {
  width: 420px;
  padding: 20px;
}

.doc-type-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-type-choices button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.doc-type-choices button:hover,
.doc-type-choices button.active {
  border-color: var(--blue);
  background: #f0f8ff;
}

.doc-type-choices .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.doc-type-choices button[data-choose-doc="入库单"] .dot {
  background: #1688dc;
}

.doc-type-choices button[data-choose-doc="生产单"] .dot {
  background: #f5a623;
}

.doc-type-choices button[data-choose-doc="发货单"] .dot {
  background: #39bd7f;
}

.ocr-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.ocr-actions .ghost-btn,
.ocr-actions .primary-btn {
  height: 48px;
  min-width: 174px;
  padding: 0 24px;
  font-size: 18px;
  line-height: 1;
}

.ocr-items-actions {
  display: flex;
  gap: 10px;
}

.ocr-items-table {
  margin-top: 8px;
}

.ocr-items-table th,
.ocr-items-table td {
  padding: 7px 5px;
  font-size: 12px;
}

.ocr-items-table th {
  white-space: nowrap;
  background: #f8fbff;
  color: #52677d;
  font-weight: 700;
}

.ocr-items-table td {
  background: #fff;
}

.ocr-items-table input,
.ocr-items-table select {
  width: 100%;
  min-width: 56px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
}

.ocr-items-table input:focus,
.ocr-items-table select:focus {
  border-color: var(--blue);
  outline: 0;
}

.ocr-items-table .row-action {
  width: 44px;
  text-align: center;
}

.ocr-items-table .row-action button {
  padding: 4px 8px;
  font-size: 12px;
  border: 0;
  border-radius: 4px;
  background: var(--red-soft);
  color: var(--red);
  cursor: pointer;
}

.ocr-totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.ocr-totals input {
  background: #f8fbff;
  font-weight: 700;
}

.ocr-result {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbff;
  color: var(--muted);
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.6;
}

.ocr-result strong {
  color: var(--text);
}

.ocr-result.ok {
  border-color: #bce7d2;
  background: var(--green-soft);
  color: #23724e;
}

.ocr-result.running {
  border-color: #b8d5ee;
  background: var(--blue-soft);
  color: #0b6da8;
}

.confidence-hint {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 7px;
  background: #fff8e6;
  border: 1px solid #f2d79c;
  color: #8a5d00;
  font-size: 13px;
  display: none;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.confidence-hint.show {
  display: flex;
}

.confidence-hint .low {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f2a10d;
  margin-top: 5px;
  flex-shrink: 0;
}

input.confidence-high,
select.confidence-high {
  border-color: #88d4a8;
  background: #f0f9f4;
}

input.confidence-medium,
select.confidence-medium {
  border-color: #f2d05d;
  background: #fffbe8;
}

input.confidence-low,
select.confidence-low {
  border-color: #f2a10d;
  background: #fff8e6;
}

input.autofilled.confidence-low,
select.autofilled.confidence-low {
  border-color: #f2a10d;
  background: #fff8e6;
  box-shadow: 0 0 0 3px rgba(242, 161, 13, 0.1);
}

.pending-products {
  margin-top: 14px;
  border: 1px solid #bce7d2;
  border-radius: 8px;
  background: #fbfffd;
  overflow: hidden;
}

.pending-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid #dff3e8;
}

.pending-head strong {
  font-size: 14px;
}

.pending-head span {
  color: #23724e;
  font-size: 12px;
  text-align: right;
}

.pending-table {
  max-height: 220px;
  overflow: auto;
}

.pending-table table {
  min-width: 620px;
  box-shadow: none;
}

.pending-table th,
.pending-table td {
  padding: 9px 10px;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 18px;
  background: #15283d;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
  transform: translateY(80px);
  opacity: 0;
  transition: 0.25s ease;
  z-index: 10;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .dashboard-grid,
  .ocr-layout {
    grid-template-columns: 1fr;
  }

  .panel.wide,
  .panel.tall {
    grid-column: auto;
    grid-row: auto;
  }
}

.stock-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.stock-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.stock-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.stock-stat-card span {
  color: var(--muted);
  font-size: 13px;
  display: block;
}

.stock-stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  line-height: 1;
}

.stock-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stock-search {
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.stock-search input {
  min-width: 180px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}

.stock-filters select {
  height: 38px;
  width: auto;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.master-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.master-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.master-tabs button {
  height: 40px;
  padding: 0 22px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: 0.18s ease;
}

.master-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.master-tabs button:not(.active):hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.master-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.master-search {
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.master-search input {
  min-width: 180px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}

.master-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.master-stat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  min-height: 108px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.master-stat-card .kpi-icon {
  width: 36px;
  height: 36px;
}

.master-stat-card span {
  color: var(--muted);
  min-height: 30px;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  display: block;
}

.master-stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 19px;
  line-height: 1;
}

.master-panel {
  margin-bottom: 16px;
}

.master-panel .table-wrap {
  margin-top: 0;
}

.settle-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ocr-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.ocr-template-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 360px) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fff, var(--blue-soft));
  box-shadow: var(--shadow);
}

.ocr-template-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

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

.ocr-template-summary span:not(.ocr-template-icon) {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.ocr-template-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
}

.ocr-template-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ocr-template-picker {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.ocr-template-modal {
  width: min(1180px, calc(100vw - 32px));
  padding: 20px;
}

.ocr-template-modal .modal-head {
  align-items: flex-start;
  margin-bottom: 14px;
}

.ocr-template-modal .modal-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.ocr-template-config {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 150px minmax(190px, 0.8fr) auto;
  align-items: end;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.ocr-template-config label,
.ocr-template-rule-editor label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.ocr-template-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ocr-template-upload span {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
}

.ocr-template-config-actions,
.ocr-template-rule-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ocr-template-config-actions .primary-btn,
.ocr-template-config-actions .ghost-btn,
.ocr-template-rule-actions .primary-btn,
.ocr-template-rule-actions .ghost-btn {
  margin-top: 0;
}

.ghost-btn.danger {
  color: var(--red);
  border-color: #f2bdc4;
}

.ocr-template-designer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  margin-top: 14px;
}

.ocr-template-canvas-panel,
.ocr-template-rules {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.ocr-template-stage {
  position: relative;
  min-height: 480px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background-color: #eef4f8;
  background-image: linear-gradient(45deg, rgba(113,130,149,.08) 25%, transparent 25%), linear-gradient(-45deg, rgba(113,130,149,.08) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(113,130,149,.08) 75%), linear-gradient(-45deg, transparent 75%, rgba(113,130,149,.08) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  touch-action: none;
}

.ocr-template-stage > img {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

#ocrTemplateImage[hidden],
#ocrTemplateEmpty[hidden],
#ocrTemplateFixedWrap[hidden] {
  display: none;
}

.ocr-template-boxes {
  position: absolute;
  pointer-events: none;
}

.ocr-template-box {
  position: absolute;
  min-width: 34px;
  min-height: 24px;
  border: 2px solid var(--blue);
  background: rgba(22, 136, 220, 0.13);
  cursor: move;
  pointer-events: auto;
  touch-action: none;
}

.ocr-template-box[data-source]:not([data-source="ocr"]) {
  border-style: dashed;
  border-color: var(--muted);
  background: rgba(113, 130, 149, 0.1);
}

.ocr-template-box.selected {
  border-color: var(--orange);
  background: rgba(242, 161, 13, 0.16);
  box-shadow: 0 0 0 3px rgba(242, 161, 13, 0.18);
}

.ocr-template-box-label {
  position: absolute;
  left: -2px;
  top: -26px;
  max-width: 200px;
  padding: 3px 7px;
  border-radius: 4px 4px 4px 0;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ocr-template-box.selected .ocr-template-box-label {
  background: var(--orange);
}

.ocr-template-resize {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 3px;
  background: var(--blue);
  cursor: nwse-resize;
}

.ocr-template-box.selected .ocr-template-resize {
  background: var(--orange);
}

.ocr-template-empty {
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.ocr-template-empty strong {
  color: var(--text);
}

.ocr-template-help {
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.ocr-template-rule-editor {
  display: grid;
  gap: 12px;
}

.ocr-template-rule-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  max-height: 360px;
  overflow: auto;
}

.ocr-template-rule-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 9px 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.ocr-template-rule-item:hover,
.ocr-template-rule-item.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.ocr-template-rule-item span {
  color: var(--muted);
  font-size: 11px;
}

.ocr-template-rule-item code {
  grid-column: 1 / -1;
  color: #53687e;
  font-size: 11px;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .ocr-template-bar,
  .ocr-template-config,
  .ocr-template-designer {
    grid-template-columns: 1fr;
  }

  .ocr-template-picker {
    grid-template-columns: 96px 1fr;
  }

  .ocr-template-stage {
    min-height: 380px;
  }
}

@media (max-width: 560px) {
  .ocr-template-modal {
    width: calc(100vw - 16px);
    max-width: none;
    max-height: calc(100vh - 16px);
    padding: 14px;
  }

  .ocr-template-stage {
    min-height: 300px;
  }

  .ocr-template-config-actions > *,
  .ocr-template-rule-actions > * {
    flex: 1;
  }
}

.ocr-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.ocr-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.ocr-stat-card span {
  color: var(--muted);
  font-size: 13px;
  display: block;
}

.ocr-stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  line-height: 1;
}

.ocr-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ocr-search {
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.ocr-search input {
  min-width: 180px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}

.ocr-filters select {
  height: 38px;
  width: auto;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.settle-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settle-tabs button {
  height: 40px;
  padding: 0 22px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: 0.18s ease;
}

.settle-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.settle-tabs button:not(.active):hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.settle-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settle-search {
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.settle-search input {
  min-width: 180px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}

.settle-filters select {
  height: 38px;
  width: auto;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.settle-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.settle-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.settle-stat-card span {
  color: var(--muted);
  font-size: 13px;
  display: block;
}

.settle-stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  line-height: 1;
}

.settle-panel {
  margin-bottom: 16px;
}

.settle-panel .table-wrap {
  margin-top: 0;
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 32px 13px !important;
  white-space: normal !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 50, 0.45);
  display: grid;
  place-items: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 620px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  padding: 24px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-head h3 {
  margin: 0;
  font-size: 19px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.modal-close:hover {
  border-color: var(--red);
  color: var(--red);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions .primary-btn,
.delivery-form-actions .primary-btn {
  margin-top: 0;
}

@media (max-width: 1180px) {
  .settle-stats {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
  .stock-stats {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
  .ocr-stats {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 820px) {
  .settle-stats {
    grid-template-columns: 1fr;
  }
  .settle-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .stock-stats {
    grid-template-columns: 1fr;
  }
  .stock-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .ocr-stats {
    grid-template-columns: 1fr;
  }
  .ocr-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .master-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .master-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .master-tabs {
    width: 100%;
    overflow-x: auto;
  }
  .master-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .modal {
    width: calc(100vw - 20px);
    padding: 16px;
  }
}

/* ─── 出库发货模块 ─── */

/* ─── 生产管理+BOM配方模块 ─── */

.production-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.production-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.production-tabs button {
  height: 40px;
  padding: 0 22px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: 0.18s ease;
}

.production-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.production-tabs button:not(.active):hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.production-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.production-search {
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.production-search input {
  min-width: 180px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}

.production-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.production-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.production-stat-card span {
  color: var(--muted);
  font-size: 13px;
  display: block;
}

.production-stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  line-height: 1;
}

.production-panel {
  margin-bottom: 16px;
}

.production-panel .table-wrap {
  margin-top: 0;
}

.bom-detail-panel,
.production-detail-panel {
  margin-top: 16px;
}

.bom-detail-info,
.production-detail-info {
  margin-bottom: 12px;
}

.bom-material-actions {
  margin: 10px 0 8px;
}

.bom-material-select {
  width: 100%;
  min-width: 140px;
  height: 32px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 0 6px;
}

.bom-qty-input {
  height: 32px;
  width: 80px;
  font-size: 12px;
  padding: 0 6px;
}

/* ─── 出库发货模块 ─── */

.delivery-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.delivery-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.delivery-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.delivery-stat-card span {
  color: var(--muted);
  font-size: 13px;
  display: block;
}

.delivery-stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  line-height: 1;
}

.delivery-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.delivery-search {
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.delivery-search input {
  min-width: 180px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}

.delivery-filters select {
  height: 38px;
  width: auto;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.delivery-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.delivery-detail-actions {
  margin: 10px 0 8px;
}

.delivery-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.delivery-product-select {
  width: 100%;
  min-width: 140px;
  height: 32px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 0 6px;
}

.delivery-detail-row input[type="number"] {
  height: 32px;
  width: 80px;
  font-size: 12px;
  padding: 0 6px;
}

.delivery-detail-row input[type="text"].delivery-remark-input {
  height: 32px;
  width: 100px;
  font-size: 12px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.delivery-detail-row .amount-cell {
  font-weight: 600;
  color: var(--blue);
}

.delivery-remove-btn {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--red);
  border-radius: 4px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
  cursor: pointer;
}

.delivery-remove-btn:hover {
  background: var(--red);
  color: #fff;
}

/* ─── Combo-field 客户/地址组合框 ─── */
.combo-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.combo-field.full-width {
  grid-column: 1 / -1;
}

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

.combo-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.combo-row select {
  width: 200px;
  min-width: 160px;
  height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
}

.combo-row input {
  flex: 1;
  min-width: 180px;
  height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
}

.combo-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.combo-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.combo-btn.save-btn {
  background: var(--blue);
  color: #fff;
  border: none;
}

.combo-btn.save-btn:not(:disabled):hover {
  background: var(--blue-2);
}

.combo-btn.del-btn {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid var(--red);
}

.combo-btn.del-btn:not(:disabled):hover {
  background: var(--red);
  color: #fff;
}

/* 当表单隐藏时，记录列表占满全宽 */
.delivery-layout:has(> #deliveryFormPanel[hidden]) {
  grid-template-columns: 1fr;
}

/* 发货记录表格：9列全部可见 */
#deliveryRows {
  table-layout: fixed;
  min-width: 100%;
  font-size: 12px;
}

#deliveryRows th,
#deliveryRows td {
  padding: 8px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#deliveryRows th:nth-child(1),
#deliveryRows td:nth-child(1) { width: 110px; }
#deliveryRows th:nth-child(2),
#deliveryRows td:nth-child(2) { width: 18%; }
#deliveryRows th:nth-child(3),
#deliveryRows td:nth-child(3) { width: 80px; }
#deliveryRows th:nth-child(4),
#deliveryRows td:nth-child(4) { width: 95px; }
#deliveryRows th:nth-child(5),
#deliveryRows td:nth-child(5) { width: 65px; }
#deliveryRows th:nth-child(6),
#deliveryRows td:nth-child(6) { width: 75px; }
#deliveryRows th:nth-child(7),
#deliveryRows td:nth-child(7) { width: 95px; }
#deliveryRows th:nth-child(8),
#deliveryRows td:nth-child(8) { width: 75px; }
#deliveryRows th:nth-child(9),
#deliveryRows td:nth-child(9) { width: 220px; }

/* 小屏下记录表格可横向滚动，避免被挤压 */
@media (max-width: 1180px) {
  .delivery-layout {
    grid-template-columns: 1fr;
  }

  #deliveryRows {
    min-width: 820px;
  }
}

/* ─── 打印专用 ─── */

.print-sheet {
  display: none;
}

@media print {
  /* 隐藏所有非打印内容 */
  .sidebar,
  .topbar,
  .nav,
  .collapse-btn,
  .brand,
  .icon-btn,
  .toast,
  .modal-overlay,
  .delivery-toolbar,
  .delivery-filters,
  .delivery-stats,
  .delivery-layout,
  .panel,
  #deliveryFormPanel,
  .delivery-form-actions,
  .delivery-detail-actions,
  .delivery-remove-btn,
  #addDeliveryProductBtn,
  #cancelDeliveryBtn,
  .combo-field,
  .ghost-btn {
    display: none !important;
  }

  /* 重置外层布局 */
  .app-shell {
    display: block !important;
  }

  .main {
    padding: 0 !important;
    margin: 0 !important;
  }

  .view {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
  }

  .view:not([data-view="delivery"]) {
    display: none !important;
  }

  /* 打印发货单铺满页面 */
  .print-sheet {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 99999;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    overflow: auto;
    font-size: 12px;
    line-height: 1.5;
    color: #000;
  }

  .print-sheet h1 {
    text-align: center;
    font-size: 20px;
    margin: 0 0 4px;
    font-weight: 700;
  }

  .print-sheet .print-company {
    text-align: center;
    margin-bottom: 6px;
  }

  .print-sheet .print-company-addr {
    font-size: 12px;
    color: #333;
    margin: 0 0 8px;
  }

  .print-sheet .print-title {
    text-align: center;
    font-size: 22px;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #333;
    font-weight: 700;
  }

  .print-sheet .print-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 30px;
    margin: 10px 0;
    font-size: 13px;
  }

  .print-sheet .print-header p {
    margin: 0;
    line-height: 1.8;
  }

  .print-sheet table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    min-width: auto;
  }

  .print-sheet th,
  .print-sheet td {
    border: 1px solid #333;
    padding: 5px 6px;
    font-size: 12px;
    text-align: left;
    white-space: normal;
  }

  .print-sheet th {
    background: #eee !important;
    font-weight: 700;
    text-align: center;
  }

  .print-sheet .col-seq {
    text-align: center;
    width: 36px;
  }

  .print-sheet tfoot td {
    font-weight: 700;
  }

  .print-sheet .print-notice {
    margin-top: 14px;
    font-size: 12px;
    color: #333;
    line-height: 1.6;
  }

  .print-sheet .print-sign {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    margin-top: 50px;
    font-size: 13px;
  }

  .print-sheet .print-sign p {
    margin: 0 0 4px;
    border-bottom: 1px solid #999;
    padding-bottom: 28px;
  }

  .print-sheet .print-remark {
    margin-top: 20px;
    font-size: 12px;
    color: #666;
    text-align: center;
  }

  @page {
    margin: 15mm;
    size: A4;
  }
}

@media (max-width: 1180px) {
  .delivery-stats {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
  .delivery-layout {
    grid-template-columns: 1fr;
  }
  .production-stats {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 820px) {
  .delivery-stats {
    grid-template-columns: 1fr;
  }
  .delivery-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .combo-row {
    flex-wrap: wrap;
  }
  .combo-row select {
    width: 100%;
    min-width: 0;
  }
  .combo-row input {
    min-width: 0;
  }
  .combo-btn {
    flex: 1;
  }
  .production-stats {
    grid-template-columns: 1fr;
  }
  .production-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .production-tabs {
    width: 100%;
    overflow-x: auto;
  }
  .production-filters {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ─── 侧栏折叠 ─── */
.sidebar-overlay {
  display: none;
}

.sidebar-closed .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.sidebar-closed .main {
  grid-column: 1 / -1;
}

/* ─── 手机自适应 ≤768px ─── */
@media (max-width: 768px) {
  button,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 98;
  }
  .sidebar-overlay.active {
    display: block;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    z-index: 99;
    transform: translateX(0);
    transition: transform 0.25s ease, opacity 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }

  .sidebar-closed .sidebar {
    transform: translateX(-100%);
  }

  .main {
    padding: 12px 14px 24px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    min-height: 56px;
    margin-bottom: 12px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .topbar p {
    font-size: 12px;
  }

  .top-actions {
    width: 100%;
    order: 3;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: wrap;
  }

  .user-chip {
    min-width: 0;
    height: 32px;
    padding: 2px 8px;
  }
  .user-chip span { font-size: 12px; }
  .user-chip small { display: none; }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .kpi-card {
    padding: 14px;
  }
  .kpi-card strong {
    font-size: 20px;
  }

  .dashboard-grid,
  .ocr-layout,
  .delivery-layout {
    grid-template-columns: 1fr;
  }

  .panel.wide,
  .panel.tall {
    grid-column: auto;
    grid-row: auto;
  }

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

  .form-grid .combo-field.full-width,
  .combo-field.full-width {
    grid-column: auto;
  }

  .combo-row {
    flex-wrap: wrap;
  }
  .combo-row select {
    width: 100%;
    min-width: 0;
  }
  .combo-row input {
    min-width: 0;
  }
  .combo-row .combo-btn {
    flex: 1;
    min-width: 0;
  }

  .settle-stats,
  .stock-stats,
  .ocr-stats,
  .master-stats,
  .delivery-stats,
  .production-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .settle-toolbar,
  .stock-filters,
  .ocr-filters,
  .master-toolbar,
  .delivery-toolbar,
  .production-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .settle-tabs,
  .master-tabs,
  .production-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .drop-zone-wrap {
    flex-direction: column;
  }

  .camera-btn {
    width: 100%;
    height: 52px;
    flex-direction: row;
    justify-content: center;
  }

  .camera-dialog {
    width: calc(100vw - 24px);
  }

  .doc-type-choices button {
    padding: 12px;
  }

  .settle-filters,
  .delivery-filters,
  .production-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .settle-filters select,
  .delivery-filters select {
    width: 100%;
  }

  .delivery-search input {
    min-width: 0;
    width: 100%;
  }

  .delivery-detail-row {
    flex-wrap: wrap;
  }

  .delivery-form-actions {
    flex-direction: column;
  }
  .delivery-form-actions button {
    width: 100%;
  }

  .modal {
    width: 100%;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    padding: 16px;
    margin: 8px;
  }

  .modal-head h3 {
    font-size: 17px;
  }

  .modal-actions {
    flex-direction: column;
  }
  .modal-actions button {
    width: 100%;
  }

  .preview {
    max-height: 200px;
  }
}

/* ─── 超小屏 ≤480px ─── */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .kpi-card {
    padding: 10px;
  }
  .kpi-card strong {
    font-size: 17px;
  }
  .kpi-card span {
    font-size: 11px;
  }

  .settle-stats,
  .stock-stats,
  .ocr-stats,
  .master-stats,
  .delivery-stats,
  .production-stats {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 8px 10px 20px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .stock-stat-card,
  .settle-stat-card,
  .ocr-stat-card,
  .master-stat-card,
  .delivery-stat-card,
  .production-stat-card {
    padding: 10px;
  }
  .stock-stat-card strong,
  .settle-stat-card strong,
  .ocr-stat-card strong,
  .master-stat-card strong,
  .delivery-stat-card strong,
  .production-stat-card strong {
    font-size: 18px;
  }

  .table-wrap {
    margin: 0 -10px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  table {
    min-width: 580px;
  }

  th, td {
    padding: 8px 10px;
    font-size: 12px;
  }

  .modal {
    padding: 12px;
    max-width: calc(100vw - 8px);
    margin: 4px;
  }

  .combo-field select,
  .combo-field input {
    height: 34px;
    font-size: 13px;
  }

  .primary-btn,
  .ghost-btn {
    height: 34px;
    font-size: 13px;
  }
}

/* ════════════════════════════════════════════════════════════
   登录遮罩层 + 权限管理
   ════════════════════════════════════════════════════════════ */

/* 未登录时锁定整个应用，禁止穿透操作 */
.app-shell.locked {
  pointer-events: none;
  filter: blur(2px);
  user-select: none;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1f3a8a 0%, #2f5fd0 60%, #4f7bf0 100%);
  padding: 24px;
}
.login-overlay.show {
  display: flex;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(15, 35, 90, 0.35);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.login-brand .brand-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2f5fd0, #4f7bf0);
  color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.login-brand strong { display: block; font-size: 16px; color: #1c2b4a; }
.login-brand span { font-size: 12px; color: #8a93a6; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .field { display: flex; flex-direction: column; gap: 6px; }
.login-form .field span { font-size: 13px; color: #5b6678; }
.login-form .field input {
  height: 42px; padding: 0 12px;
  border: 1px solid #d7dce6; border-radius: 10px;
  font-size: 14px; outline: none; transition: border-color .15s;
}
.login-form .field input:focus { border-color: #2f5fd0; }
.login-form .primary-btn { height: 44px; font-size: 15px; margin-top: 4px; }
.tenant-login-card { max-width: 420px; }
.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #2f5fd0;
  font-size: 12px;
  font-weight: 700;
}
.text-button:hover { text-decoration: underline; }
.auth-secondary { width: 100%; height: 42px; }
.register-summary {
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid rgba(45, 91, 216, 0.12);
  border-radius: 12px;
  background: #f4f6fa;
  color: #3a465c;
  font-size: 13px;
  line-height: 1.6;
}
.register-summary strong { display: block; color: #121a2b; }
.cloud-sync-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  color: #69768c;
  font-size: 11px;
}
.cloud-sync-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #39bd7f;
}
.cloud-sync-state.error::before { background: #e94b5b; }
.cloud-sync-state[hidden] { display: none; }

.cloud-permission-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}
.cloud-permission-head h2 { margin: 0; font-size: 18px; }
.cloud-permission-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.cloud-user-list { display: grid; gap: 12px; padding: 0 18px 18px; }
.cloud-user-card {
  display: grid;
  grid-template-columns: minmax(160px, .8fr) minmax(360px, 2fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(20, 32, 56, 0.08);
  border-radius: 12px;
  background: #f8fbff;
}
.cloud-user-card strong, .cloud-user-card small { display: block; }
.cloud-user-card small { margin-top: 4px; color: var(--muted); }
.permission-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.permission-chip { position: relative; }
.permission-chip input { position: absolute; opacity: 0; pointer-events: none; }
.permission-chip span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.permission-chip input:checked + span {
  border-color: rgba(45, 91, 216, 0.3);
  background: #eef3fe;
  color: #2f5fd0;
  font-weight: 700;
}
.permission-chip input:checked + span::before { content: "✓"; margin-right: 5px; }
.permission-chip input:focus-visible + span { outline: 3px solid rgba(45, 91, 216, 0.18); }
.cloud-user-actions { display: flex; align-items: center; gap: 8px; }
.cloud-invite-result {
  margin: 0 18px 18px;
  padding: 14px;
  border-radius: 12px;
  background: #eef3fe;
  color: #2f5fd0;
  font-size: 13px;
  word-break: break-all;
}
.cloud-invite-result code { font-family: ui-monospace, Menlo, Consolas, monospace; }
.cloud-empty {
  margin: 0 18px 18px;
  padding: 32px 18px;
  border-radius: 12px;
  background: #f8fbff;
  color: var(--muted);
  text-align: center;
}

.login-hint {
  margin-top: 18px;
  font-size: 12px;
  color: #7a8395;
  line-height: 1.7;
}
.login-hint code {
  background: #eef2fb; color: #2f5fd0;
  padding: 1px 6px; border-radius: 5px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* ===== 密钥授权（激活）遮罩 ===== */
.license-card { max-width: 420px; }
.license-device {
  background: #f5f7fc; border: 1px solid #e6ebf5; border-radius: 12px;
  padding: 14px 16px; margin-bottom: 18px;
}
.lic-label { font-size: 12px; color: #6b7488; }
.lic-device-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; }
.lic-device-row code {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; font-weight: 700;
  color: #1f3a8a; letter-spacing: 1px; flex: 1;
}
.copy-mini {
  border: 1px solid #cdd6e6; background: #fff; color: #2f5fd0;
  border-radius: 6px; padding: 4px 12px; font-size: 12px; cursor: pointer; transition: all .15s;
}
.copy-mini:hover { background: #eef3fe; border-color: #2f5fd0; }
.lic-tip { font-size: 12px; color: #8a93a6; line-height: 1.6; }
.lic-error { min-height: 18px; margin-top: 10px; font-size: 12px; color: #e24b4a; line-height: 1.5; }

/* 顶栏授权剩余天数 */
.license-info {
  font-size: 12px; color: #2f7d4f; background: #eaf6ee;
  padding: 3px 10px; border-radius: 20px; white-space: nowrap;
}
.license-info.warn { color: #c0392b; background: #fdeaea; }

/* 侧栏导航板块徽标 */
.nav-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.nav-badge.finance { background: #fff0e8; color: #d9651f; }
.nav-badge.ops { background: #e8f1ff; color: #2f5fd0; }
.nav-badge.admin { background: #eef0f4; color: #5b6678; }

/* 权限管理页 */
.perm-note {
  padding: 16px 18px;
  line-height: 1.9;
  font-size: 14px;
  color: #3c4659;
}
.perm-note p { margin: 0 0 6px; }
.row-actions { display: flex; gap: 10px; }
.link-btn.danger { color: #d23b3b; }
.link-btn.danger:disabled { color: #c4c9d2; cursor: not-allowed; }

/* 移动端：登录卡与徽标适配 */
@media (max-width: 480px) {
  .login-card { padding: 26px 20px; }
  .nav-badge { font-size: 10px; padding: 2px 6px; }
}

@media (max-width: 900px) {
  .cloud-user-card { grid-template-columns: 1fr; }
  .cloud-user-actions { justify-content: flex-start; }
}

@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;
  }
}

/* 侧栏退出系统按钮（左下角） */
.logout-btn {
  margin-top: 10px;
  height: 40px;
  border: 1px solid #f1c4c4;
  border-radius: 8px;
  background: #fff6f6;
  color: #d6453d;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: 0.18s ease;
}
.logout-btn:hover { background: #fde7e7; }
.logout-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

/* 权限管理：角色模块勾选网格 */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px 18px;
  padding: 16px 18px;
}
.module-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 2px;
}
.module-check input { width: 16px; height: 16px; accent-color: #2f5fd0; }
.module-check.finance { color: #c0392b; }
.module-check.operations { color: #2f7d4f; }
.module-check .nav-badge { position: static; margin-left: 2px; }
