/* 进销存后台 · 参考主流后台（清爽卡片 + 深色侧栏） */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #e8e8e8;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --primary-soft: #e6f4ff;
  --danger: #ff4d4f;
  --danger-soft: #fff2f0;
  --success: #52c41a;
  --sidebar-bg: #001529;
  --sidebar-hover: #ffffff14;
  --sidebar-active-bg: #1677ff;
  --sidebar-text: rgba(255, 255, 255, 0.75);
  --sidebar-text-active: #fff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.06);
  --font: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
  z-index: 200;
}

.sidebar-brand {
  padding: 1.1rem 1.25rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  opacity: 0.55;
  margin-top: 0.2rem;
  letter-spacing: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.sidebar-nav .nav-section {
  padding: 0.35rem 0.75rem 0.25rem;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.45;
  color: rgba(255, 255, 255, 0.9);
}

.sidebar-nav a.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 2px 0.65rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.sidebar-nav a.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 500;
}

.sidebar-nav a.nav-item .ni {
  width: 1.25rem;
  text-align: center;
  opacity: 0.9;
  font-size: 15px;
}

.sidebar-foot {
  padding: 1rem 1.25rem;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-foot strong {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
}

.sidebar-foot a {
  color: rgba(255, 255, 255, 0.65);
  margin-top: 0.35rem;
  display: inline-block;
}

.sidebar-foot a:hover {
  color: #fff;
}

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main-topbar {
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: min(200px, 38vw);
  padding: 0.2rem 0.65rem 0.2rem 0.5rem;
  border-radius: 999px;
  background: #f4f6f9;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip a.user-name {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.user-chip a.user-name:hover {
  text-decoration: underline;
  color: var(--primary);
}

.user-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.topbar-logout {
  text-decoration: none;
}

.topbar-logout:hover {
  text-decoration: none;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
}

.nav-toggle:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.nav-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 21, 41, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.app-layout.nav-open .nav-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sidebar-foot-meta {
  font-size: 11px;
  opacity: 0.55;
  padding: 0.65rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.65);
}

.main-topbar .crumb {
  font-size: 13px;
  color: var(--text-secondary);
}

.main-topbar .crumb b {
  color: var(--text);
  font-weight: 600;
}

.main-body {
  flex: 1;
  padding: 1.25rem 1.5rem 2rem;
  overflow-x: auto;
}

#app-main {
  max-width: 1400px;
  margin: 0 auto;
}

#app-main > h1.page-title {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.dash-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dash-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(22, 119, 255, 0.12);
  text-decoration: none;
  color: var(--text);
}

.dash-card strong {
  font-size: 0.95rem;
  font-weight: 600;
}

.dash-card span {
  font-size: 12px;
  color: var(--text-secondary);
}

#app-main h2.section-title {
  margin: 1.25rem 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}

.toolbar form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* 主区 + 登录页：所有可编辑输入统一圆角（覆盖微信/WebKit 搜索框等默认方形外观） */
#app-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="range"]),
#app-main textarea,
#app-main select:not([multiple]),
body.login-standalone input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
body.login-standalone textarea {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  min-height: 34px;
  min-width: 0;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

#app-main textarea,
body.login-standalone textarea {
  min-height: 80px;
  resize: vertical;
  width: 100%;
  max-width: 100%;
}

#app-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="range"]),
#app-main select:not([multiple]),
body.login-standalone input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]) {
  min-width: 100px;
}

#app-main input:focus,
#app-main textarea:focus,
#app-main select:focus,
body.login-standalone input:focus,
body.login-standalone textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  min-height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button:hover,
.btn:hover {
  border-color: #d0d0d0;
  background: #fafafa;
}

button.primary,
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

button.primary:hover,
.btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

button.danger,
.btn.danger {
  background: var(--danger-soft);
  border-color: #ffccc7;
  color: var(--danger);
}

button.danger:hover,
.btn.danger:hover {
  background: #ffe8e6;
}

button.small,
.btn.small {
  padding: 0.2rem 0.55rem;
  min-height: 28px;
  font-size: 12px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* 单据明细表内可搜索下拉，不能用 overflow:hidden 裁切面板 */
table.data.lines-editor {
  overflow: visible;
}

/* 横向滚动只包在表格外层，避免 .panel overflow 裁切下拉层 */
.lines-editor-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  /* 与下方「加一行」等兄弟节点分层，避免仅一行明细时下拉被按钮挡住 */
  position: relative;
  z-index: 5;
}

/* 商品档案等宽表：横向滚动，仍按页从服务端拉取 */
.table-scroll-wide {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll-wide table.data {
  min-width: 960px;
}

.cell-ellipsis {
  cursor: help;
}

.form-grid .lines-editor-scroll ~ p {
  position: relative;
  z-index: 0;
}

#app-main .panel:has(.lines-editor-scroll) {
  overflow: visible;
}

table.data th,
table.data td {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0.75rem;
  text-align: left;
  vertical-align: middle;
}

table.data th {
  background: #fafafa;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

table.data tbody tr:hover td {
  background: #fafbff;
}

.pager {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.muted {
  color: var(--text-secondary);
  font-size: 12px;
}

.msg {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.msg.err {
  background: var(--danger-soft);
  border: 1px solid #ffccc7;
  color: #cf1322;
}

.msg.ok {
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  color: #389e0d;
}

.err-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.err-state h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  color: var(--text);
}

.err-state p {
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  word-break: break-word;
}

.form-grid {
  display: grid;
  /* min(100%, 260px)：窄屏（H5）自动单列，避免横向挤成一窄条 */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 0.75rem 1.1rem;
  align-items: start;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 0;
}

.form-grid label input,
.form-grid label textarea,
.form-grid label select {
  width: 100%;
  max-width: 100%;
}

.form-grid label span {
  font-weight: 500;
  color: var(--text);
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.loading::before {
  content: "";
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.page-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
}

.page-state--loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.page-state--loading::before {
  content: "";
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.page-state--deny {
  text-align: left;
  max-width: 520px;
  margin: 0 auto;
}

.page-state--deny .page-title {
  margin-top: 0;
}

.grid-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

table.lines-editor input,
table.lines-editor select.line-sku-select,
table.lines-editor .combo,
table.lines-editor .combo-input {
  width: 100%;
  min-width: 0;
}

/* 进货单 / 送货单 明细编辑：表头与单元格居中，与名称列内控件对齐 */
table.lines-editor-mid th,
table.lines-editor-mid td {
  text-align: center;
  vertical-align: middle;
}

.line-cell-c {
  text-align: center;
}

.line-input-c {
  text-align: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.do-name-cell .combo {
  margin-top: 0.35rem;
}

.do-name-cell .combo-input {
  width: 100%;
  text-align: center;
}

/* 当前行获得焦点时抬高层级，避免下拉被下一行遮挡 */
table.lines-editor tbody tr {
  position: relative;
}

table.lines-editor tbody tr:focus-within {
  z-index: 25;
}

/* 可搜索选择器（替代原生 select） */
.combo {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  z-index: 1;
}

.combo-input {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius) !important;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

/* 主区内 combo：提高优先级，覆盖 #app-main input 在部分 WebView 下与「搜索框」组合导致的文字不显示 */
#app-main .combo-input {
  color: var(--text);
  background-color: #fff;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  opacity: 1;
}

.combo-input::-webkit-search-decoration,
.combo-input::-webkit-search-cancel-button,
.combo-input::-webkit-search-results-button,
.combo-input::-webkit-search-results-decoration {
  display: none;
}

#app-main .combo-input:-webkit-autofill,
#app-main .combo-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text) !important;
  box-shadow: 0 0 0 1000px #fff inset;
  transition: background-color 99999s ease-out;
}

.combo-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  max-height: min(280px, 52vh);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.25rem;
}

/* JS 在打开列表时加类并写 inline，避免被 overflow-x 滚动容器纵向裁切 */
.combo-panel.combo-panel-fixed {
  right: auto;
}

.combo-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  margin: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.combo-item:hover {
  background: var(--primary-soft);
}

.radio-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 13px;
  color: var(--text);
}

.radio-inline label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}

.radio-inline input[type="radio"] {
  min-height: auto;
  min-width: auto;
}

.invoice-pickdo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.invoice-pickdo-row .combo {
  flex: 1 1 220px;
  min-width: 0;
}

@media (max-width: 768px) {
  .main-topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    row-gap: 0.35rem;
    padding: 0.45rem 1rem;
  }

  .topbar-right {
    flex-shrink: 1;
    min-width: 0;
  }

  /* 报表等：表格在 .panel 内嵌套 div 时也要能横向滑动 */
  #app-main .panel .grid-2col {
    grid-template-columns: 1fr;
  }

  #app-main .panel .grid-2col > div {
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app-main .panel .grid-2col > div table.data {
    min-width: 260px;
  }

  /* 电子送货单 / 进货清单：不在 .panel 内，窄屏允许横向滑读宽表 */
  #app-main .delivery-slip {
    max-width: 100%;
    padding: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app-main .delivery-slip-vertical {
    max-width: 100%;
  }

  #app-main .delivery-slip .dsl-goods {
    min-width: 520px;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(288px, 88vw);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }

  .app-layout.nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.2);
  }

  .main-wrap {
    width: 100%;
  }

  .main-body {
    padding: 1rem;
  }

  #app-main > h1.page-title {
    font-size: 1.15rem;
  }

  .dash-cards {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar form {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  #app-main .toolbar form input[type="text"],
  #app-main .toolbar form input[type="search"],
  #app-main .toolbar form input[type="number"] {
    width: 100%;
    min-width: 0 !important;
    max-width: none;
    flex: 1 1 auto;
  }

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

  .form-grid textarea {
    min-width: 0;
  }

  .panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app-main .panel:has(.lines-editor-scroll) {
    overflow: visible;
  }

  #app-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="range"]),
  #app-main textarea,
  #app-main select.line-sku-select,
  #app-main .combo-input {
    min-height: 44px;
  }

  body.login-standalone input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
  body.login-standalone textarea {
    min-height: 44px;
  }

  #app-main button,
  #app-main .btn {
    min-height: 44px;
  }

  #app-main .lines-editor-scroll {
    display: block;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  #app-main .lines-editor-scroll table.data {
    min-width: 640px;
  }

  /* 列表页主表格：避免列被压成「一坨」，横向滑动阅读 */
  #app-main .panel > table.data {
    min-width: 680px;
  }

  /* 单据截图预览：尽量用满屏宽，长图仍可滚动 */
  .app-modal-slip {
    width: min(calc(100vw - 20px), 100%);
    max-width: 100%;
  }

  .app-modal-overlay.app-modal-slipimg {
    padding: 10px 8px;
    align-items: flex-start;
  }
}

/* 登录/改密独立页（与后台表单控件统一圆角） */
body.login-standalone {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
  font-family: var(--font);
  color: var(--text);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.35rem 1.25rem;
}

.login-card h1 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.login-card form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.75rem;
  font-size: 12px;
  color: var(--text-secondary);
}

.login-card form label span {
  font-weight: 500;
  color: var(--text);
}

.login-card form input {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius);
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

.login-card button.primary,
.login-card button.btn.primary {
  width: 100%;
  margin-top: 1rem;
}

.login-card #msg {
  margin-top: 0.85rem;
  font-size: 13px;
  white-space: pre-wrap;
}

.login-card #msg.ok {
  color: var(--success);
}

.login-card #msg.err {
  color: var(--danger);
}

.slip-toolbar a.btn {
  text-decoration: none;
}

.slip-toolbar a.btn:hover {
  text-decoration: none;
}

.field-search-select {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field-search-select .line-product-filter,
.field-search-select .party-filter {
  width: 100%;
  max-width: 100%;
}

.form-field-party {
  grid-column: 1 / -1;
  margin-bottom: 0.35rem;
  position: relative;
  z-index: 1;
}

/* 客户/供货商等顶部 Combo 展开时盖住下方「明细」表头，避免列表被挡 */
.form-field-party:has(.combo-input:focus) {
  z-index: 60;
}

.form-field-party > label > span {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-secondary);
}

/* 报表筛选行：客户 combo 不占整行，和其它输入保持对齐 */
.report-filter-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  align-items: end;
}

.report-filter-grid .form-field-party {
  grid-column: auto;
  margin-bottom: 0;
}

.report-filter-grid .report-filter-btn {
  width: 100%;
}

.btn-success {
  background: #f6ffed !important;
  border-color: #b7eb8f !important;
  color: #389e0d !important;
}

.btn-success:hover {
  background: #d9f7be !important;
  border-color: #95de64 !important;
}

/* 电子送货单 / 进货清单工具栏 */
.slip-toolbar,
.delivery-slip-toolbar {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.slip-toolbar a,
.slip-toolbar button,
.delivery-slip-toolbar a,
.delivery-slip-toolbar button {
  margin-right: 0;
}

.delivery-slip {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  background: #fff;
  border: 1px solid #222;
  color: #111;
  font-size: 13px;
}

/* 竖版送货单：偏窄版心，贴近纸质联单 */
.delivery-slip-vertical {
  max-width: 680px;
}

/*
 * 离屏截图：克隆挂在 body 下，不在 #app-main 内，需显式版心宽度，否则与屏显/HTML2Canvas 布局不一致。
 */
.slip-capture-host {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  color: #111;
}

.delivery-slip-vertical.delivery-slip--capture {
  width: 680px;
  max-width: 680px;
  margin: 0;
}

.delivery-slip-po.delivery-slip--capture {
  width: 900px;
  max-width: 900px;
  margin: 0;
}

.slip-capture-host .dsl-seller-footer {
  max-width: none;
}

/* 账户设置：公章预览 */
.seller-seal-preview {
  display: block;
  max-height: 120px;
  width: auto;
  margin-top: 0.35rem;
  object-fit: contain;
}

.seller-seal-panel-inner .seller-seal-actions {
  margin-top: 0.5rem;
}

.dsl-header {
  text-align: center;
  margin-bottom: 1rem;
  border-bottom: 2px solid #111;
  padding-bottom: 0.75rem;
}

/* 进货清单：标题几何居中，右侧中文日期，不展示单号 */
.dsl-header-po-slip {
  text-align: center;
}

.dsl-po-slip-title-band {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 0.25rem 0.5rem;
  min-height: 2.5rem;
  margin-bottom: 0;
}

.dsl-header-po-slip .dsl-title {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: 0.35em;
  font-weight: 700;
  text-align: center;
  justify-self: center;
}

.dsl-po-slip-date {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-self: end;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.delivery-slip-po .dsl-note {
  text-align: center;
}

/* 竖版参考：标题居中，右下红色编号（无「单号」文案）；下一行左客户、右中文日期 */
.dsl-header-vertical {
  text-align: left;
}

/* 三列 1fr | auto | 1fr：标题在中间列几何居中，右上格放编号 */
.dsl-title-band {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 0.25rem 0.5rem;
  min-height: 2.75rem;
  margin-bottom: 0.5rem;
}

.dsl-header-vertical .dsl-title {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  padding: 0;
  font-size: 1.65rem;
  letter-spacing: 0.35em;
  font-weight: 700;
  text-align: center;
  justify-self: center;
}

.dsl-stamp-ts {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-self: end;
  max-width: min(100%, 12.5rem);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
  word-break: break-all;
}

.dsl-stamp-val {
  font-weight: 700;
  color: #b30d0d;
  letter-spacing: 0.02em;
}

.dsl-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  padding-top: 0.15rem;
}

.dsl-customer {
  flex: 1;
  min-width: min(100%, 12rem);
  text-align: left;
  font-size: 14px;
}

/* 送货单抬头：客户 + 联系电话分段，段与段之间留白 */
.dsl-customer-slip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
}

.dsl-customer .dsl-k {
  font-weight: 600;
  color: #111;
  margin-right: 0.15rem;
}

.dsl-customer-slip-head .dsl-ch-seg {
  display: inline-block;
  max-width: 100%;
}

.dsl-date {
  flex-shrink: 0;
  text-align: right;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.dsl-order-remark {
  margin: 0 0 0.65rem;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}

.dsl-title {
  margin: 0 0 0.5rem;
  font-size: 1.65rem;
  letter-spacing: 0.35em;
  font-weight: 700;
}

.dsl-meta {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.dsl-meta p {
  margin: 0;
}

.dsl-k {
  color: #444;
  margin-right: 0.25rem;
}

.dsl-party,
.dsl-goods {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}

.dsl-party th,
.dsl-party td,
.dsl-goods th,
.dsl-goods td {
  border: 1px solid #222;
  padding: 6px 8px;
  vertical-align: top;
}

.dsl-party th {
  width: 88px;
  background: #f5f5f5;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.dsl-party td {
  text-align: left;
}

.dsl-seller th {
  width: 88px;
}

.dsl-goods thead th {
  background: #f0f0f0;
  font-weight: 600;
  text-align: center;
}

.dsl-c {
  text-align: center;
}

.dsl-l {
  text-align: left;
}

.dsl-r {
  text-align: right;
}

.dsl-goods tfoot td {
  font-size: 1.02em;
  border-top: 2px solid #111;
}

.dsl-slip-cells-center th,
.dsl-slip-cells-center td {
  text-align: center !important;
}

.dsl-total-upper {
  text-align: center !important;
  font-size: 13px;
  line-height: 1.45;
}

/* 送货单表尾：合计（大写）+ 大写金额（下划线）+ ￥ + 小写金额（下划线）；靠右 */
.dsl-slip-total-one {
  font-size: 13px;
  line-height: 1.85;
  padding-top: 0.65rem !important;
  padding-bottom: 0.75rem !important;
}

.dsl-slip-total-one strong {
  font-size: 13px;
  font-weight: 600;
}

.dsl-goods.dsl-slip-cells-center tfoot td.dsl-slip-total-one {
  text-align: right !important;
  padding-right: 2.5em;
}

/* 大写、小写金额共用下划线（底边，便于打印/截图）；大写由 rmbAmountInWords 生成（已含元角分及万仟佰拾等读法） */
.dsl-slip-amount-under {
  display: inline-block;
  margin-left: 0.25em;
  margin-right: 0.2em;
  padding-bottom: 4px;
  border-bottom: 1px solid currentColor;
  vertical-align: baseline;
  line-height: 1.45;
  font-weight: 600;
}


/* ￥与「合计」同字号、不加粗、无下划线，两侧空格用字面量保留 */
.dsl-slip-yuan-sym {
  font-size: 13px;
  font-weight: 400;
  white-space: pre;
}

.dsl-slip-yuan-sym + .dsl-slip-amount-under {
  margin-left: 0;
}

.dsl-sign {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 2.5rem;
  padding-top: 0.5rem;
}

.dsl-sign-seller-only {
  justify-content: flex-start;
}

.dsl-sign-box {
  flex: 1;
  min-height: 72px;
  border-top: 1px solid #333;
  padding-top: 6px;
  text-align: center;
  color: #333;
}

.dsl-sign-box-seller {
  max-width: 100%;
  text-align: left;
  min-height: auto;
  overflow-x: visible;
}

.dsl-seller-wrap {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  line-height: 1.55;
  color: #333;
}

/* 送货单底部：每行 flex；标签为自然宽度+冒号+正文紧挨（禁用固定宽 justify，避免三字标签拉散） */
.dsl-seller-footer {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/*
 * 章叠在卖方块内、不占流式高度；实务与常见说明：
 * - 宜压在「本单位名称」一带、印迹完整，避免挡金额/单号/日期等关键字段（简道云等进销存说明、法律场景共识）。
 * - 多单据右下常留给「客户签收」；卖方出库章多落在卖方信息左/中侧单位名称处，少压「联系电话」与表格外框。
 */
.dsl-seller-footer-text--stamped {
  position: relative;
  overflow: visible;
}

.dsl-seller-footer-text-stack {
  position: relative;
  z-index: 1;
}

/* 勿对透明 PNG 章加 opacity：部分 WebView/Chrome 合成层会把 alpha 误成黑底 */
.dsl-company-seal {
  position: absolute;
  /* 略让出「送货单位：」标签宽度，章主要落在单位名称区域；可按字体再调 left */
  left: 5rem;
  right: auto;
  bottom: 0.1rem;
  z-index: 0;
  max-width: 92px;
  max-height: 92px;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left bottom;
  background: transparent;
  pointer-events: none;
}

.dsl-seller-footer-text {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* 标签与冒号紧贴；覆盖全局 .dsl-k 的 margin-right */
.dsl-seller-footer .dsl-sell-lbl.dsl-k {
  margin-right: 0;
}

.dsl-seller-flex-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  column-gap: 0.35rem;
  row-gap: 0.3rem;
  width: 100%;
}

/* 左段：块级占位即可，内部用行内流排版（不用 flex 包一层再包 inline-flex，避免换行算法抽风） */
.dsl-sell-left-line {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: calc(100% - 11rem);
  box-sizing: border-box;
}

/* 一组「标签：值」：字面全角冒号紧跟标签，值与冒号同一行内流，超长再换行 */
.dsl-sell-kv {
  display: inline-block;
  max-width: 100%;
  vertical-align: baseline;
  box-sizing: border-box;
}

.dsl-sell-kv--wrap .dsl-sell-inline-val {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* 联系人 / 电话：整段不换行，过长时由外层 flex 换到下一行 */
.dsl-sell-kv--nowrap {
  white-space: nowrap;
}

.dsl-sell-inline-val {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.dsl-sell-right-line {
  flex: 0 0 auto;
}

.dsl-sell-right-combo {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  column-gap: 0.35rem;
  row-gap: 0.25rem;
}

/* 送货单位 与 联系人 之间、联系人 与 联系电话 之间略加大空距（再一倍） */
.dsl-seller-footer .dsl-seller-flex-row--unit-contact {
  column-gap: 2rem;
}

.dsl-seller-footer .dsl-sell-right-combo {
  column-gap: 1.5rem;
}

.dsl-seller-flex-row--unit-contact .dsl-sell-left-line {
  max-width: calc(100% - 22rem);
}

/* 送货单底部第二行：卖方备注纯文本，无标签，从行首起排满后自然换行 */
.dsl-seller-org-remark-row {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.55;
  min-width: 0;
}

/* 送货单底部标签：随文字宽度，不拉散 */
.dsl-seller-footer .dsl-sell-lbl {
  white-space: nowrap;
  line-height: 1.55;
}

.dsl-seller-footer .dsl-seller-val {
  white-space: nowrap;
}

.dsl-note {
  margin-top: 1rem;
  font-size: 12px;
}

/* Toast：右下角，约 2 秒消失；避让刘海屏安全区 */
.toast-root {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
}

.toast-item {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast-item.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-item.toast-out {
  opacity: 0;
  transform: translateY(6px);
}

.toast-info {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.toast-success {
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  color: #135200;
}

.toast-warn {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  color: #614700;
}

/* 自定义确认框、图片预览；内边距含安全区（全面屏 / 微信内置浏览器） */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

.app-modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  max-width: 100%;
  box-sizing: border-box;
}

.app-modal-confirm {
  width: min(400px, 100%);
  padding: 1.25rem 1.35rem;
}

.app-modal-text {
  margin: 0 0 1.15rem;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

.app-modal-actions {
  display: flex;
  gap: 0.65rem;
  justify-content: flex-end;
}

.app-modal-slip {
  position: relative;
  width: min(560px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  padding: 1rem 1rem 1.25rem;
}

.app-modal-slip-hint {
  margin: 0 0 0.75rem;
  font-size: 13px;
}

.app-modal-slip-wrap {
  text-align: center;
  background: #f5f5f5;
  border-radius: var(--radius-sm);
  padding: 8px;
}

.app-modal-slip-img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  -webkit-touch-callout: default;
  user-select: none;
}

.app-modal-close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
}

.app-modal-close:hover {
  background: var(--border);
  color: var(--text);
}

/* 草稿页 / 列表离屏打印：仅打印送货单，不显示后台框架 */
.slip-print-anchor {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 680px;
  max-width: 680px;
  z-index: -1;
  pointer-events: none;
  overflow: visible;
}

.slip-print-anchor.slip-print-anchor--po {
  width: 900px;
  max-width: 900px;
}

@media print {
  body.admin-print-slip-only .app-layout {
    display: none !important;
  }

  body.admin-print-slip-only .slip-print-anchor {
    display: block !important;
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    z-index: auto !important;
    pointer-events: auto !important;
  }

  .no-print,
  .sidebar,
  .nav-backdrop,
  .main-topbar,
  .nav-toggle,
  .toast-root,
  .app-modal-overlay,
  .slip-capture-host {
    display: none !important;
  }

  .app-layout {
    display: block;
  }

  .main-wrap {
    width: 100% !important;
    margin: 0;
  }

  .main-body {
    padding: 0 !important;
  }

  #app-main {
    padding: 0;
  }

  .delivery-slip {
    border: none;
    max-width: none;
    margin: 0;
    padding: 0.5rem;
  }

  .dsl-sign-box-seller {
    overflow-x: visible;
  }

  .dsl-seller-val {
    overflow-x: visible;
    white-space: normal;
    word-break: break-word;
  }

  body {
    background: #fff;
  }
}
