:root {
  --ink: #17211e;
  --muted: #69736f;
  --line: #dce3df;
  --surface: #ffffff;
  --canvas: #f3f6f4;
  --soft: #e8f2ed;
  --primary: #176b53;
  --primary-dark: #0e4f3d;
  --accent: #e7a923;
  --accent-soft: #fff6dc;
  --danger: #bd3f38;
  --danger-soft: #fff0ee;
  --blue: #326b9f;
  --shadow: 0 14px 36px rgba(18, 50, 39, 0.08);
  --sidebar-width: 252px;
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

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

button { color: inherit; }

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(23, 107, 83, 0.22);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

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

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 26px 18px 20px;
  color: #f7fbf9;
  background: #123c31;
  border-right: 1px solid rgba(255,255,255,0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 8px 30px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: #163a31;
  background: #f1bb3f;
  border-radius: 8px;
  font-weight: 900;
}

.brand-mark svg { width: 25px; height: 25px; stroke-width: 2.5; }
.brand strong { display: block; font-size: 22px; }
.brand small { display: block; margin-top: 3px; color: rgba(255,255,255,.66); font-size: 13px; }

.nav-list { display: grid; gap: 5px; }

.nav-item {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  color: rgba(255,255,255,.67);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
  transition: background .18s ease, color .18s ease;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.11); }
.nav-item.active::before { content: ""; position: absolute; left: 0; width: 3px; height: 24px; background: var(--accent); border-radius: 0 3px 3px 0; }

.nav-count {
  min-width: 22px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  color: rgba(255,255,255,.72);
  background: rgba(255,255,255,.09);
  border-radius: 10px;
  font-size: 12px;
}

.session-note {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 7px;
}

.session-note svg { width: 20px; color: #83d1b7; }
.session-note strong, .session-note small { display: block; }
.session-note strong { font-size: 14px; }
.session-note small { margin-top: 4px; color: rgba(255,255,255,.6); font-size: 12px; line-height: 1.45; }

.main-column { min-height: 100vh; margin-left: var(--sidebar-width); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 clamp(22px, 4vw, 52px);
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.mobile-brand { display: none; align-items: center; gap: 11px; margin-right: auto; }
.mobile-brand .brand-mark { width: 42px; height: 42px; }
.mobile-brand .brand-mark svg { width: 23px; height: 23px; }
.mobile-brand strong { font-size: 19px; }

.network-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 18px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot { width: 7px; height: 7px; background: #34a574; border-radius: 50%; box-shadow: 0 0 0 3px #e2f5ed; }
.network-status.offline .status-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.language-picker {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  color: var(--muted);
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.language-picker svg { width: 18px; height: 18px; flex: 0 0 auto; }
.language-picker select {
  max-width: 134px;
  padding: 0 17px 0 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.icon-button:hover { background: var(--canvas); border-color: var(--line); }
.icon-button svg { width: 18px; height: 18px; }
.icon-button.light { background: var(--surface); border-color: var(--line); }
.icon-button.light:hover { border-color: #aebbb5; }

.profile-button {
  min-height: 50px;
  display: grid;
  grid-template-columns: 40px auto 17px;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 4px 5px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.profile-button:hover { background: var(--canvas); border-color: var(--line); }
.profile-button > svg { width: 17px; color: var(--muted); }
.avatar { width: 40px; height: 40px; display: grid; place-items: center; color: #fff; background: #4e6c62; border-radius: 50%; font-size: 15px; font-weight: 700; }
.profile-copy strong, .profile-copy small { display: block; }
.profile-copy strong { font-size: 14px; }
.profile-copy small { margin-top: 3px; color: var(--muted); font-size: 12px; }

main { max-width: 1320px; margin: 0 auto; padding: 36px clamp(22px, 4vw, 52px) 80px; }
.app-view { display: none; animation: view-in .24s ease; }
.app-view.active { display: block; }

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

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.page-heading-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.share-site-button { border-color: rgba(23, 107, 83, .28); color: var(--primary); background: #f4fbf8; }
.share-site-button:hover { background: #e9f7f1; border-color: rgba(23, 107, 83, .42); }

.page-heading h1 { margin: 4px 0 8px; font-size: clamp(29px, 3vw, 38px); line-height: 1.25; }
.page-heading p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.7; }
.page-heading .eyebrow { color: var(--primary); font-size: 13px; font-weight: 800; text-transform: uppercase; }

.primary-button,
.secondary-button,
.text-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: transform .16s ease, background .16s ease, border .16s ease;
}

.primary-button:active,
.secondary-button:active { transform: translateY(1px); }
.primary-button { color: #fff; background: var(--primary); border: 1px solid var(--primary); box-shadow: 0 5px 14px rgba(23,107,83,.16); }
.primary-button:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.primary-button:disabled, .secondary-button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.secondary-button { color: var(--ink); background: var(--surface); border: 1px solid #cbd5d0; }
.secondary-button:hover { border-color: #8fa29a; background: #fafcfb; }
.text-button { min-height: 34px; padding: 0 8px; color: var(--primary); background: transparent; border: 0; box-shadow: none; }
.text-button:hover { background: var(--soft); }
.primary-button svg, .secondary-button svg, .text-button svg { width: 17px; height: 17px; }
.primary-button.wide { width: 100%; }
.secondary-button.compact { min-height: 38px; padding: 0 13px; }

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 20px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  list-style: none;
  overflow: hidden;
}

.workflow-steps li {
  position: relative;
  min-height: 80px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 20px;
  color: #85908b;
  border-right: 1px solid var(--line);
}

.workflow-steps li:last-child { border-right: 0; }
.workflow-steps li > span { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid #c7d0cc; border-radius: 50%; font-size: 13px; font-weight: 800; }
.workflow-steps strong, .workflow-steps small { display: block; }
.workflow-steps strong { color: inherit; font-size: 15px; }
.workflow-steps small { margin-top: 4px; font-size: 12px; }
.workflow-steps li.active { color: var(--primary); background: #f8fbf9; }
.workflow-steps li.active > span { color: #fff; background: var(--primary); border-color: var(--primary); }
.workflow-steps li.done > span { color: #fff; background: #3e9b79; border-color: #3e9b79; }
.workflow-steps li.done > span { font-size: 0; }
.workflow-steps li.done > span::after { content: "✓"; font-size: 13px; }

.work-section,
.order-section {
  margin-top: 16px;
  padding: clamp(18px, 2.7vw, 28px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(24, 47, 39, .035);
}

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 19px; }
.section-heading > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.section-heading h2 { margin: 0; font-size: 20px; }
.step-kicker { color: var(--primary); font-size: 13px; font-weight: 900; }
.required-label, .muted-label, .order-number { color: var(--muted); font-size: 13px; }
.required-label { color: var(--danger); }
.order-number { font-family: Consolas, monospace; }

.material-grid { display: grid; grid-template-columns: repeat(6, minmax(112px, 1fr)); gap: 10px; }

.material-option {
  position: relative;
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}

.material-option:hover { border-color: #9fb2aa; background: #fff; }
.material-option.selected { background: #f2f8f5; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.material-option > span:nth-child(2) { min-width: 0; }
.material-option strong, .material-option small { display: block; }
.material-option strong { overflow-wrap: anywhere; font-size: 15px; line-height: 1.25; }
.material-option small { margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; font-size: 11px; line-height: 1.35; }
.material-option > svg { position: absolute; top: 6px; right: 6px; width: 14px; height: 14px; padding: 2px; color: #fff; background: var(--primary); border-radius: 50%; opacity: 0; }
.material-option.selected > svg { opacity: 1; }

.material-visual { width: 33px; height: 33px; flex: 0 0 auto; display: grid; place-content: center; grid-template-columns: repeat(2, auto); gap: 2px; background: #e7ece9; border-radius: 6px; overflow: hidden; }
.material-visual b { display: block; }
.material-visual.pipes b, .material-visual.logs b { width: 10px; height: 10px; border: 3px solid #66756f; border-radius: 50%; }
.material-visual.logs { background: #eee4d4; }
.material-visual.logs b { border-color: #8f6740; }
.material-visual.rebars { display: flex; align-items: center; }
.material-visual.rebars b { width: 5px; height: 27px; background: repeating-linear-gradient(180deg,#725f54 0 3px,#9d8b7e 3px 6px); border-radius: 2px; transform: rotate(26deg); }
.material-visual.timber { background: #f0e5d1; }
.material-visual.timber b { width: 12px; height: 21px; background: #aa7f4f; border: 2px solid #805c36; border-radius: 1px; }
.material-visual.squares b { width: 11px; height: 11px; border: 3px solid #63736c; }
.material-visual.buckles b { width: 13px; height: 13px; border: 3px solid #7a7060; border-radius: 50%; box-shadow: inset 0 0 0 2px #e7ece9; }

.upload-panel {
  min-height: 268px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 26px;
  background: #f8faf9;
  border: 1px dashed #a9b8b1;
  border-radius: 7px;
  transition: background .18s ease, border .18s ease;
}

.upload-panel.dragover { background: var(--soft); border-color: var(--primary); }
.upload-visual { position: relative; width: 124px; height: 68px; display: grid; place-items: center; margin-bottom: 2px; }
.pipe-stack { width: 80px; display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.pipe-stack span { width: 19px; height: 19px; background: #77847f; border: 5px solid #4d5a55; border-radius: 50%; box-shadow: inset 0 0 0 2px #cfd7d3; }
.scan-corner { position: absolute; width: 19px; height: 19px; border-color: var(--primary); border-style: solid; }
.scan-corner.top-left { top: 0; left: 0; border-width: 2px 0 0 2px; }
.scan-corner.top-right { top: 0; right: 0; border-width: 2px 2px 0 0; }
.scan-corner.bottom-left { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.scan-corner.bottom-right { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
.upload-copy { text-align: center; }
.upload-copy h3 { margin: 0 0 7px; font-size: 18px; }
.upload-copy p { margin: 0; color: var(--muted); font-size: 13px; }
.upload-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px; margin-top: 6px; }

.recognition-area { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(260px, .72fr); gap: 18px; }
.image-workbench { min-width: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #202825; }
.canvas-toolbar { min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 10px 7px 14px; color: var(--ink); background: var(--surface); border-bottom: 1px solid var(--line); }
.canvas-toolbar > div { display: flex; align-items: center; gap: 9px; }
.canvas-toolbar strong { font-size: 14px; }
.live-badge { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.live-badge > span { width: 6px; height: 6px; background: #34a574; border-radius: 50%; }
.tool-group { display: flex; gap: 6px; }
.canvas-wrap { position: relative; min-height: 380px; display: grid; place-items: center; overflow: hidden; background: #202825; touch-action: manipulation; }
#recognitionCanvas { display: block; max-width: 100%; max-height: 570px; cursor: crosshair; }
.analyzing-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; color: #fff; background: rgba(17,27,24,.76); overflow: hidden; }
.analyzing-overlay strong { font-size: 14px; }
.analyzing-overlay small { color: rgba(255,255,255,.65); font-size: 10px; }
.scan-line { position: absolute; left: 8%; right: 8%; top: 10%; height: 1px; background: #5ee0af; box-shadow: 0 0 16px #5ee0af; animation: scan 1.8s ease-in-out infinite alternate; }
@keyframes scan { to { top: 90%; } }
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.edit-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 7px 11px; color: #fff; background: rgba(12,27,22,.84); border-radius: 5px; font-size: 10px; text-align: center; }
.image-strip { min-height: 72px; display: flex; gap: 8px; padding: 9px; background: var(--surface); border-top: 1px solid var(--line); overflow-x: auto; }
.image-thumb { position: relative; flex: 0 0 70px; height: 52px; padding: 0; background: #e5ebe8; border: 2px solid transparent; border-radius: 5px; overflow: hidden; cursor: pointer; }
.image-thumb.selected { border-color: var(--primary); }
.image-thumb img { width: 100%; height: 100%; object-fit: cover; }
.image-thumb span { position: absolute; right: 3px; bottom: 3px; min-width: 18px; height: 17px; display: grid; place-items: center; padding: 0 4px; color: #fff; background: rgba(12,28,22,.82); border-radius: 3px; font-size: 9px; font-weight: 800; }

.result-panel { align-self: stretch; padding: 20px; background: #f8faf9; border: 1px solid var(--line); border-radius: 7px; }
.result-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.confidence { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border-radius: 4px; font-size: 11px; font-weight: 800; }
.confidence svg { width: 12px; height: 12px; }
.confidence.high { color: #176b53; background: #e5f3ed; }
.confidence.medium { color: #8b6410; background: var(--accent-soft); }
.confidence.low { color: var(--danger); background: var(--danger-soft); }
.quantity-display { display: flex; align-items: baseline; justify-content: center; gap: 7px; margin: 28px 0 1px; }
.quantity-display strong { font-family: Arial, sans-serif; font-size: 64px; line-height: 1; }
.quantity-display span { color: var(--muted); font-size: 15px; }
.quantity-caption { margin: 0 0 23px; color: var(--muted); font-size: 12px; text-align: center; }
.correction-control { min-height: 58px; display: grid; grid-template-columns: 48px 1fr 48px; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.correction-control button { display: grid; place-items: center; background: transparent; border: 0; cursor: pointer; }
.correction-control button:first-child { border-right: 1px solid var(--line); }
.correction-control button:last-child { border-left: 1px solid var(--line); }
.correction-control button:hover { background: var(--soft); color: var(--primary); }
.correction-control button svg { width: 18px; }
.correction-control > div { display: flex; align-items: center; justify-content: center; gap: 8px; }
.correction-control span { color: var(--muted); font-size: 12px; }
.correction-control strong { font-size: 15px; }
.quality-note { display: flex; align-items: flex-start; gap: 8px; min-height: 50px; margin: 14px 0; padding: 11px; color: #52645d; background: #edf5f1; border-radius: 5px; font-size: 12px; line-height: 1.6; }
.quality-note.warning { color: #775819; background: var(--accent-soft); }
.quality-note svg { flex: 0 0 auto; width: 15px; height: 15px; color: var(--primary); }
.quality-note.warning svg { color: #b78012; }

.order-section { scroll-margin-top: 84px; }
.auto-link-banner { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; margin: calc(clamp(18px, 2.7vw, 28px) * -1) calc(clamp(18px, 2.7vw, 28px) * -1) 25px; padding: 14px clamp(18px, 2.7vw, 28px); background: #edf6f2; border-bottom: 1px solid #cbe2d8; border-radius: 8px 8px 0 0; }
.auto-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--primary); background: #d6ece3; border-radius: 6px; }
.auto-icon svg { width: 18px; }
.auto-link-banner strong, .auto-link-banner span:not(.auto-icon):not(.draft-badge) { display: block; }
.auto-link-banner strong { font-size: 14px; }
.auto-link-banner div > span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.draft-badge, .status-badge { display: inline-flex; align-items: center; justify-content: center; min-height: 26px; padding: 0 10px; border-radius: 4px; font-size: 12px; font-weight: 800; }
.draft-badge { color: #8a6212; background: var(--accent-soft); border: 1px solid #f0d990; }
.draft-badge.generated, .status-badge.generated { color: var(--primary); background: #e4f2ec; }
.status-badge.signed { color: var(--blue); background: #eaf2f8; }
.status-badge.voided { color: var(--danger); background: var(--danger-soft); }
.status-badge.draft { color: #8a6212; background: var(--accent-soft); }

.line-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
.line-table, .ledger-table { width: 100%; border-collapse: collapse; }
.line-table th { height: 42px; padding: 0 11px; color: var(--muted); background: #f5f7f6; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; white-space: nowrap; }
.line-table td { min-width: 95px; padding: 10px 11px; border-bottom: 1px solid #edf0ee; font-size: 14px; }
.line-table tr:last-child td { border-bottom: 0; }
.line-table input, .line-table select { width: 100%; min-width: 82px; height: 36px; padding: 0 9px; color: var(--ink); background: #fff; border: 1px solid #ccd6d1; border-radius: 5px; }
.line-table .readonly-cell { font-weight: 700; }
.line-table .amount-cell { font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 22px; }
.field { display: grid; gap: 8px; color: #48544f; font-size: 13px; }
.field > span b { color: var(--danger); }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea, .filter-bar select {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd5d0;
  border-radius: 6px;
}
.field input, .field select { height: 46px; padding: 0 13px; }
.field textarea { padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field input[readonly], .field input:disabled, .line-table input:disabled, .line-table select:disabled { color: #59635f; background: #f1f4f2; }
.field.invalid input { border-color: var(--danger); background: #fffafa; }

.order-summary { display: flex; justify-content: flex-end; gap: 38px; margin-top: 20px; padding: 17px 3px; border-top: 1px dashed #cbd4d0; border-bottom: 1px dashed #cbd4d0; }
.order-summary > div { display: flex; align-items: baseline; gap: 10px; }
.order-summary span { color: var(--muted); font-size: 13px; }
.order-summary strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.order-summary > div:last-child strong { color: var(--primary); }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.form-actions > div { display: flex; gap: 9px; }
.generated-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; padding: 15px; background: #edf6f2; border: 1px solid #cce3d9; border-radius: 6px; }
.generated-actions > div { display: flex; align-items: center; gap: 10px; }
.generated-actions > div:first-child > svg { width: 25px; height: 25px; color: var(--primary); }
.generated-actions strong, .generated-actions small { display: block; }
.generated-actions strong { font-size: 14px; }
.generated-actions small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.search-box { min-width: 260px; flex: 1; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 11px; background: #f8faf9; border: 1px solid #d7dfdb; border-radius: 5px; }
.search-box svg { width: 16px; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 14px; }
.filter-bar select { width: auto; min-width: 150px; height: 42px; padding: 0 32px 0 12px; font-size: 14px; }

.history-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.history-card { display: grid; grid-template-columns: 112px 1fr; min-height: 122px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; cursor: pointer; }
.history-card:hover { border-color: #9fb2aa; box-shadow: var(--shadow); }
.history-card img { width: 112px; height: 100%; object-fit: cover; background: #dfe6e2; }
.history-card > div { min-width: 0; display: flex; flex-direction: column; padding: 13px; }
.history-card header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.history-card h2 { margin: 0; font-size: 15px; }
.history-card .history-count { color: var(--primary); font-size: 18px; font-weight: 900; }
.history-card p { margin: auto 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.history-card small { color: #8b9691; font-size: 11px; }

.empty-state { min-height: 340px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; color: var(--muted); text-align: center; }
.empty-state h2 { margin: 13px 0 5px; color: var(--ink); font-size: 19px; }
.empty-state p { margin: 0 0 17px; font-size: 13px; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; color: #6f837b; background: #e5ece9; border-radius: 50%; }
.empty-icon svg { width: 24px; }

.metric-row { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.metric-item { min-height: 112px; padding: 22px 24px; border-right: 1px solid var(--line); }
.metric-item:last-child { border-right: 0; }
.metric-item span, .metric-item small { display: block; color: var(--muted); font-size: 12px; }
.metric-item strong { display: inline-block; margin-top: 11px; font-family: Arial, sans-serif; font-size: 28px; }
.metric-item small { display: inline-block; margin-left: 5px; }
.metric-item.accent { background: #f6faf8; }
.metric-item.accent strong { color: var(--primary); }

.table-shell { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; overflow-x: auto; }
.ledger-table th { height: 46px; padding: 0 14px; color: var(--muted); background: #f5f7f6; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; white-space: nowrap; }
.ledger-table td { padding: 15px 14px; border-bottom: 1px solid #e9eeeb; font-size: 13px; white-space: nowrap; }
.ledger-table tbody tr:hover { background: #fafcfb; }
.ledger-table tbody tr:last-child td { border-bottom: 0; }
.ledger-table .number-cell { color: var(--primary); font-family: Consolas, monospace; font-weight: 700; }
.ledger-table .action-button { width: 32px; height: 32px; display: grid; place-items: center; background: transparent; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.ledger-table .action-button svg { width: 15px; }
.table-empty { min-width: 760px; }

.report-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(310px, .7fr); gap: 16px; }
.report-panel { min-height: 380px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.panel-heading span { color: var(--muted); font-size: 12px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 19px; }
.period-chip { padding: 6px 9px; background: var(--canvas); border: 1px solid var(--line); border-radius: 4px; }
.bar-chart { min-height: 270px; display: flex; align-items: flex-end; gap: clamp(8px, 2vw, 20px); padding: 20px 8px 0; border-bottom: 1px solid var(--line); }
.bar-column { min-width: 34px; height: 245px; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; }
.bar-column strong { color: var(--muted); font-size: 12px; }
.bar-column svg { width: min(44px, 68%); height: 190px; display: block; overflow: visible; }
.bar-column rect { fill: var(--primary); }
.bar-column:nth-child(2n) rect { fill: #4c7d9d; }
.bar-column:nth-child(3n) rect { fill: #d09a29; }
.bar-column span { color: var(--muted); font-size: 12px; }
.report-empty { width: 100%; align-self: center; color: var(--muted); font-size: 13px; text-align: center; }
.customer-ranking { display: grid; gap: 18px; }
.rank-item { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; }
.rank-number { width: 24px; height: 24px; display: grid; place-items: center; color: var(--muted); background: var(--canvas); border-radius: 4px; font-size: 10px; font-weight: 800; }
.rank-item:first-child .rank-number { color: #77540e; background: var(--accent-soft); }
.rank-info { min-width: 0; }
.rank-info strong, .rank-info span { display: block; }
.rank-info strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { height: 5px; margin-top: 7px; background: #e8edea; border-radius: 3px; overflow: hidden; }
.rank-track svg { width: 100%; height: 100%; display: block; }
.rank-track rect { fill: var(--primary); }
.rank-item > strong { font-size: 13px; }

.mobile-nav { display: none; }

.modal {
  width: min(calc(100vw - 32px), 840px);
  max-height: min(90vh, 900px);
  padding: 0;
  background: transparent;
  border: 0;
  overflow: visible;
}
.modal::backdrop { background: rgba(12, 26, 21, .58); backdrop-filter: blur(3px); }
.modal[open] { animation: modal-in .18s ease; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-card { max-height: min(90vh, 900px); padding: 23px; background: var(--surface); border: 1px solid rgba(255,255,255,.5); border-radius: 8px; box-shadow: 0 24px 70px rgba(4,20,14,.26); overflow-y: auto; }
.compact-modal { width: 100%; max-width: 460px; margin: 0 auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.modal-header > div { display: flex; align-items: center; gap: 11px; }
.modal-header h2 { margin: 0; font-size: 21px; }
.modal-header p { margin: 0 0 2px; color: var(--muted); font-size: 9px; }
.modal-icon { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; color: var(--primary); background: var(--soft); border-radius: 6px; }
.modal-icon svg { width: 18px; }
.modal-lead { margin: -5px 0 19px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.compact-modal > .field { margin-top: 13px; }
.account-type { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; margin-top: 16px; padding: 13px 14px; background: #f4f8f6; border: 1px solid var(--line); border-radius: 6px; }
.account-type > span { color: var(--muted); font-size: 13px; }
.account-type strong { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-size: 14px; }
.account-type strong svg { width: 17px; height: 17px; }
.account-type small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; line-height: 1.5; }
.compact-modal > .primary-button { margin-top: 20px; }
.detail-card { width: 100%; max-width: 820px; margin: 0 auto; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.detail-item { min-height: 68px; padding: 12px; background: #fff; }
.detail-item span, .detail-item strong { display: block; }
.detail-item span { color: var(--muted); font-size: 9px; }
.detail-item strong { margin-top: 7px; font-size: 12px; }
.detail-evidence { display: grid; grid-template-columns: 180px 1fr; gap: 14px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-evidence img { width: 180px; height: 125px; object-fit: cover; background: #e5ebe8; border-radius: 5px; }
.detail-evidence h3 { margin: 0 0 7px; font-size: 13px; }
.detail-evidence p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.detail-lines { margin-top: 16px; }
.detail-lines h3 { margin: 0 0 9px; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 19px; padding-top: 16px; border-top: 1px solid var(--line); }
.danger-button { color: var(--danger); border-color: #e6b9b5; }
.danger-button:hover { color: #8d2c27; background: var(--danger-soft); border-color: #d99690; }

.signature-card { width: 100%; max-width: 600px; margin: 0 auto; }
.signature-pad-wrap { position: relative; margin: 18px 0; }
.signature-pad-wrap > span { display: block; margin-bottom: 7px; color: #48544f; font-size: 11px; }
#signatureCanvas { width: 100%; height: 210px; display: block; background: #fbfcfb; border: 1px dashed #9facA6; border-radius: 6px; touch-action: none; }
.signature-pad-wrap .text-button { position: absolute; right: 7px; bottom: 7px; background: rgba(255,255,255,.9); }

.share-card { width: 100%; max-width: 760px; margin: 0 auto; }
.share-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-bottom: 18px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.share-summary > div { min-width: 0; padding: 11px 13px; background: #f8faf9; }
.share-summary span, .share-summary strong { display: block; }
.share-summary span { color: var(--muted); font-size: 9px; }
.share-summary strong { margin-top: 4px; overflow-wrap: anywhere; font-size: 12px; line-height: 1.35; }
.social-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.social-button { min-width: 0; min-height: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px 6px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font: inherit; font-size: 10px; font-weight: 700; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.social-button:hover { background: #f8faf9; border-color: #aebcb6; transform: translateY(-1px); }
.social-button:focus-visible { outline: 3px solid rgba(23,107,83,.2); outline-offset: 2px; }
.social-button > span:last-child { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.social-logo { width: 38px; height: 38px; display: grid; place-items: center; background: #3d4852; border-radius: 50%; }
.social-logo img { width: 21px; height: 21px; display: block; filter: brightness(0) invert(1); }
.social-facebook .social-logo { background: #0866ff; }
.social-x .social-logo, .social-tiktok .social-logo { background: #000; }
.social-whatsapp .social-logo { background: #25d366; }
.social-reddit .social-logo { background: #ff4500; }
.social-instagram .social-logo { background: linear-gradient(145deg, #833ab4, #fd1d1d 58%, #fcb045); }
.social-wechat .social-logo { background: #07c160; }
.social-line .social-logo { background: #06c755; }
.social-kakao .social-logo { background: #fee500; }
.social-kakao .social-logo img { filter: none; }
.social-zalo .social-logo { background: #0068ff; }
.share-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 17px; padding-top: 16px; border-top: 1px solid var(--line); }
.wechat-panel { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 18px 24px; align-items: center; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.wechat-panel-heading { align-self: start; }
.wechat-panel-heading strong { display: block; font-size: 14px; }
.wechat-panel-heading p, .wechat-note { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.wechat-status { display: inline-block; margin-top: 12px; padding: 5px 8px; color: var(--primary-dark); background: var(--soft); border-radius: 4px; font-size: 9px; font-weight: 800; }
.wechat-qr { width: 190px; height: 190px; grid-column: 2; grid-row: 1 / span 2; display: grid; place-items: center; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.wechat-qr svg { width: 100%; height: 100%; display: block; }
.wechat-note { align-self: start; margin: 0; }
[dir="rtl"] .share-actions { justify-content: flex-start; }
[dir="rtl"] .material-option { text-align: right; }
[dir="rtl"] .material-option > svg { right: auto; left: 6px; }
.clipboard-helper { position: fixed; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.toast-region { position: fixed; z-index: 100; right: 24px; bottom: 24px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 260px; max-width: min(380px, calc(100vw - 32px)); display: grid; grid-template-columns: 24px 1fr; align-items: start; gap: 8px; padding: 13px 15px; color: #fff; background: #16352b; border-radius: 6px; box-shadow: 0 16px 36px rgba(3,24,16,.2); animation: toast-in .25s ease; font-size: 11px; line-height: 1.55; }
.toast.error { background: #7f2f2a; }
.toast.warning { color: #392d12; background: #f0c55e; }
.toast svg { width: 18px; height: 18px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1120px) {
  .material-grid { grid-template-columns: repeat(3, 1fr); }
  .history-grid { grid-template-columns: repeat(2, 1fr); }
  .recognition-area { grid-template-columns: minmax(0, 1.35fr) minmax(250px, .65fr); }
}

@media (max-width: 860px) {
  :root { --sidebar-width: 0px; }
  .sidebar { display: none; }
  .main-column { margin-left: 0; }
  .topbar { min-height: 70px; padding: 0 16px; }
  .mobile-brand { display: flex; }
  main { padding: 26px 16px 104px; }
  .recognition-area { grid-template-columns: 1fr; }
  .canvas-wrap { min-height: 320px; }
  .result-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; align-items: center; }
  .result-topline, .quality-note, .result-panel > .wide { grid-column: 1 / -1; }
  .quantity-display { margin: 10px 0 0; }
  .quantity-caption { margin: 0; }
  .correction-control { grid-row: span 2; }
  .mobile-nav { position: fixed; z-index: 18; right: 0; bottom: 0; left: 0; min-height: 76px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); background: rgba(255,255,255,.97); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(23,45,37,.06); }
  .mobile-nav button { min-width: 0; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: var(--muted); background: transparent; border: 0; font-size: 12px; }
  .mobile-nav button svg { width: 24px; height: 24px; }
  .mobile-nav button.active { color: var(--primary); font-weight: 800; }
  .report-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .network-status, .profile-copy, .profile-button > svg, .topbar .icon-button { display: none; }
  .language-picker { padding: 0 5px; }
  .language-picker select { max-width: 108px; font-size: 12px; }
  .profile-button { grid-template-columns: 40px; padding: 2px; }
  .page-heading { align-items: flex-start; margin-bottom: 18px; }
  .page-heading-actions { gap: 8px; }
  .page-heading .compact { width: 42px; min-width: 42px; min-height: 42px; padding: 0; }
  .page-heading .compact span { display: none; }
  .page-heading h1 { font-size: 28px; }
  .workflow-steps li { min-height: 60px; justify-content: center; padding: 10px 8px; }
  .workflow-steps li > div { display: none; }
  .workflow-steps li::after { content: attr(data-step); display: none; }
  .work-section, .order-section { padding: 16px; }
  .material-grid { grid-template-columns: repeat(2, 1fr); }
  .material-option { min-height: 68px; }
  .upload-panel { min-height: 292px; padding: 22px 13px; }
  .upload-actions { width: 100%; }
  .upload-actions .primary-button, .upload-actions .secondary-button { flex: 1; padding: 0 10px; }
  .upload-actions .text-button { flex-basis: 100%; }
  .upload-copy p { max-width: 270px; }
  .canvas-wrap { min-height: 250px; }
  .result-panel { display: block; padding: 16px; }
  .quantity-display { margin: 18px 0 2px; }
  .quantity-display strong { font-size: 54px; }
  .quantity-caption { margin-bottom: 17px; }
  .quality-note { margin: 12px 0; }
  .auto-link-banner { grid-template-columns: 34px 1fr; margin: -16px -16px 21px; padding: 13px 16px; }
  .auto-link-banner .draft-badge { grid-column: 2; justify-self: start; }
  .form-grid { grid-template-columns: 1fr; gap: 13px; }
  .field.full { grid-column: auto; }
  .order-summary { justify-content: space-between; gap: 10px; }
  .order-summary > div { display: grid; gap: 5px; }
  .order-summary strong { font-size: 15px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions > button, .form-actions > div, .form-actions > div button { flex: 1; }
  .generated-actions { align-items: stretch; flex-direction: column; }
  .generated-actions > div:last-child { display: grid; grid-template-columns: repeat(3, 1fr); }
  .generated-actions button { padding: 0 8px; font-size: 12px; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .search-box, .filter-bar select { width: 100%; min-width: 0; }
  .history-grid { grid-template-columns: 1fr; }
  .history-card { grid-template-columns: 96px 1fr; }
  .history-card img { width: 96px; }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .metric-item { padding: 17px; }
  .metric-item:nth-child(2) { border-right: 0; }
  .metric-item.accent { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-evidence { grid-template-columns: 1fr; }
  .detail-evidence img { width: 100%; height: 190px; }
  .modal-card { padding: 20px; }
  .social-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .social-button { min-height: 70px; flex-direction: row; justify-content: flex-start; padding: 9px 11px; text-align: left; }
  .social-button > span:last-child { width: auto; }
  .social-logo { width: 34px; height: 34px; flex: 0 0 auto; }
  .social-logo img { width: 19px; height: 19px; }
  .share-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .share-actions button { min-width: 0; padding-right: 8px; padding-left: 8px; }
  .wechat-panel { grid-template-columns: 1fr; }
  .wechat-qr { grid-column: 1; grid-row: auto; justify-self: center; }
  .toast-region { right: 16px; bottom: 78px; left: 16px; }
  .toast { min-width: 0; width: 100%; }
}

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

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .sidebar, .topbar, .mobile-nav, .workflow-steps, .page-heading, #view-count > .work-section, .auto-link-banner, .form-actions, .generated-actions, .toast-region { display: none !important; }
  .main-column { margin: 0; }
  main { max-width: none; padding: 0; }
  .app-view { display: none !important; }
  #view-count { display: block !important; }
  .order-section { display: block !important; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .order-section::before { content: "数材 · 物资出库单"; display: block; margin-bottom: 8mm; padding-bottom: 5mm; border-bottom: 2px solid #17211e; font-size: 24px; font-weight: 900; }
  .section-heading.order-heading { margin-bottom: 5mm; }
  .line-table input, .line-table select, .field input, .field textarea { border: 0; padding: 0; background: transparent; appearance: none; }
  .line-table-wrap { border-color: #999; }
  .field { break-inside: avoid; }
  .order-summary { border-color: #999; }
}
