:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --bg: #f1f5f9;
  --sidebar-bg: #0f172a;
  --sidebar-text: #e2e8f0;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --danger: #dc2626;
  --warn: #d97706;
  --success: #16a34a;
  --info: #0891b2;
  --radius: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }

/* ===== 登录视图 ===== */
.login-view { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.login-card { background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { font-size: 44px; text-align: center; margin-bottom: 8px; }
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 6px; color: var(--text); }
.login-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.login-card .form-field { margin-bottom: 16px; }
.otp-row { display: flex; gap: 8px; }
.otp-row input { flex: 1; }
.otp-row .btn { flex-shrink: 0; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; text-align: center; }
.login-submit { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.login-tip { margin-top: 16px; text-align: center; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.chip-logout { margin-left: 8px; background: transparent; border: 1px solid var(--sidebar-text); color: var(--sidebar-text); border-radius: 6px; padding: 2px 8px; font-size: 11px; cursor: pointer; }
.chip-logout:hover { background: var(--sidebar-text); color: var(--sidebar-bg); }

/* 按钮 */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-size: 13px; transition: all .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 认证页 */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.auth-card { background: #fff; border-radius: 16px; padding: 40px; width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-logo { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.auth-tabs { display: flex; gap: 10px; margin-bottom: 20px; }
.auth-tab { flex: 1; padding: 8px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; }
.auth-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.auth-form .field { margin-bottom: 16px; }
.auth-form label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text); }
.auth-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.auth-form input:focus { outline: none; border-color: var(--primary); }
.otp-row { display: flex; gap: 10px; }
.otp-row input { flex: 1; }
.otp-row .btn { flex-shrink: 0; }
.field-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 4px; }
.auth-tip { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 12px; }

/* 主布局 */
.app-wrap { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { width: 240px; background: var(--sidebar-bg); display: flex; flex-direction: column; flex-shrink: 0; z-index: 50; }
.sidebar-logo { padding: 20px 18px; color: #fff; font-weight: 700; font-size: 16px; border-bottom: 1px solid #1e293b; flex-shrink: 0; }
.menu { flex: 1; overflow-y: auto; padding: 10px 0; -webkit-overflow-scrolling: touch; min-height: 0; }
.menu-group-title { padding: 10px 18px 6px; font-size: 12px; color: #94a3b8; font-weight: 600; letter-spacing: 1px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 18px; color: var(--sidebar-text); cursor: pointer; font-size: 13px; border-left: 3px solid transparent; -webkit-tap-highlight-color: transparent; }
.menu-item:hover { background: #1e293b; color: #fff; }
.menu-item.active { background: #1e293b; color: #fff; border-left-color: var(--primary); }
.menu-item .mi-icon { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 14px 18px; border-top: 1px solid #1e293b; flex-shrink: 0; }
.user-chip { color: #e2e8f0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-mask { display: none; }
.menu-toggle { display: none; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 20px; flex-shrink: 0; }
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; margin-left: auto; }
.content { flex: 1; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; }

/* 卡片与统计 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 18px; border: 1px solid var(--border); }
.stat-card .stat-label { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; }
.stat-card .stat-value.danger { color: var(--danger); }
.stat-card .stat-value.warn { color: var(--warn); }
.stat-card .stat-value.success { color: var(--success); }
.stat-card .stat-value.info { color: var(--info); }

.card { background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 20px; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 18px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: #f8fafc; padding: 10px 12px; text-align: left; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: #f8fafc; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .actions { white-space: nowrap; }
.data-table .actions .btn { margin-right: 4px; }

/* 标签 */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.tag-gray { background: #f1f5f9; color: #64748b; }
.tag-green { background: #dcfce7; color: #16a34a; }
.tag-red { background: #fee2e2; color: #dc2626; }
.tag-yellow { background: #fef3c7; color: #d97706; }
.tag-blue { background: #dbeafe; color: #2563eb; }
.tag-purple { background: #ede9fe; color: #7c3aed; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .field.full { grid-column: 1 / -1; }
.form-grid .form-field.full { grid-column: 1 / -1; }
.form-field label { display: block; margin-bottom: 6px; font-size: 13px; }
.form-field label .req { color: var(--danger); }
.form-field input, .form-field select, .form-field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--primary); }
.form-field textarea { resize: vertical; min-height: 60px; }
/* 可搜索下拉（物料 / 供应商 / 成品共用） */
.mat-search, .supp-search, .prod-search { margin-bottom: 6px; }
.mat-search::placeholder, .supp-search::placeholder, .prod-search::placeholder { color: #94a3b8; }
.mat-search-hint, .supp-search-hint, .prod-search-hint { margin-top: 5px; font-size: 12px; line-height: 1.4; color: #b45309; }
.mat-search-hint.hidden, .supp-search-hint.hidden, .prod-search-hint.hidden { display: none; }

/* 可搜索下拉组合控件：输入关键词后，结果直接在搜索框下方以列表浮出 */
.sel-combo-field { position: relative; }
.sel-combo-field.sel-open { z-index: 30; }
.sel-value-hidden { display: none !important; }
/* 选中值已直接显示在搜索框里；状态节点仅保留给读屏与程序化读取，视觉上不占一行 */
.sel-current { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sel-combo-field input.is-selected { background: #f8fafc; cursor: pointer; }
.sel-panel { position: absolute; left: 0; z-index: 60; width: 100%; min-width: 260px; max-height: 240px; overflow-y: auto; overscroll-behavior: contain; padding: 4px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 28px rgba(15, 23, 42, .18); }
.sel-panel.hidden { display: none; }
.sel-option { padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.sel-option:hover, .sel-option.is-active { background: #eff6ff; }
.sel-option-main { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-option-sub { margin-top: 2px; font-size: 11px; line-height: 1.3; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-option.sel-clear .sel-option-main, .sel-option.sel-empty .sel-option-main { font-size: 12px; color: var(--text-muted); }
.sel-option.sel-empty { cursor: default; }
.sel-option.sel-empty:hover, .sel-option.sel-empty.is-active { background: transparent; }
/* BOM 明细行较窄，结果面板加宽以完整显示编码/名称/规格/单位 */
.bom-mat-wrap .sel-panel { min-width: 320px; }
/* 浮动结果面板：挂到 body 上做固定定位，不受明细区 / 弹窗的滚动容器裁切，长列表可完整滚动查看 */
.sel-panel.sel-panel-float { position: fixed; z-index: 1200; min-width: 0; width: auto; }
.sel-panel.sel-panel-float .sel-option-main { font-size: 13px; }
.sel-panel.sel-panel-float .sel-option { padding: 8px 12px; }

/* 全局自动增强：不在 .form-field 内的下拉（筛选栏 / 工具栏 / 明细行）包一层定位容器 */
.sel-combo-inline { display: block; position: relative; flex: 1 1 180px; min-width: 150px; max-width: 100%; }
.sel-combo-inline > input.sel-generic-search { width: 100%; }
.sel-generic-search { margin-bottom: 6px; }
.sel-generic-search::placeholder { color: #94a3b8; }
.sel-generic-hint { margin-top: 5px; font-size: 12px; line-height: 1.4; color: #b45309; }
.sel-generic-hint.hidden { display: none; }
.toolbar .sel-generic-search, .filter-bar .sel-generic-search { margin-bottom: 0; }
.toolbar .sel-combo-inline, .filter-bar .sel-combo-inline { align-self: center; }
.pk-item-row .sel-combo-inline, .st-item-row .sel-combo-inline { min-width: 0; }
/* 盘点明细行的外层是纵向 flex，包裹层不能按 180px 的 flex-basis 撑高 */
.st-item-mat-wrap > .sel-combo-inline { flex: 0 0 auto; min-width: 0; }

/* 领料单多产品清单 */
.pk-items { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; max-height: 340px; overflow-y: auto; }
.pk-item-row { display: grid; grid-template-columns: 22px minmax(220px, 2.6fr) 100px minmax(120px, 1fr) auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.pk-item-row:last-child { border-bottom: none; }
.pk-item-row select, .pk-item-row input { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.pk-idx { font-size: 12px; color: var(--text-muted); text-align: center; }
.pk-item-info { font-size: 11px; color: var(--text-muted); line-height: 1.3; }
.pk-empty { padding: 14px 0; text-align: center; font-size: 13px; color: var(--text-muted); }
.pk-detail-table { font-size: 12px; margin-top: 4px; }
.edit-tip { background: #fef9c3; border: 1px solid #fde047; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; line-height: 1.6; color: #854d0e; margin-bottom: 14px; }

/* 盘点单多产品清单 */
.st-item-row { display: grid; grid-template-columns: 22px minmax(200px, 2.4fr) 88px 110px 88px auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.st-item-row:last-child { border-bottom: none; }
.st-item-row select, .st-item-row input { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.st-item-mat-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.st-item-hint { font-size: 11px; line-height: 1.3; color: #b45309; }
.st-item-hint.hidden { display: none; }
.st-item-book { font-size: 12px; color: var(--text-muted); text-align: right; white-space: nowrap; }
.st-item-diff { font-size: 12px; font-weight: 600; text-align: right; white-space: nowrap; }
.st-errors { margin-top: 8px; padding: 9px 12px; border: 1px solid #fecaca; background: #fef2f2; color: #b91c1c; border-radius: 6px; font-size: 12px; line-height: 1.6; white-space: pre-line; }
.st-errors.hidden { display: none; }

/* 入库单多商品明细 */
.in-items-head { display: flex; align-items: baseline; gap: 10px; margin: 14px 0 6px; flex-wrap: wrap; }
.in-items-title { font-size: 13px; font-weight: 600; }
.in-items-tip { font-size: 11px; color: var(--text-muted); }
.in-items-box { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; max-height: 320px; overflow-y: auto; }
.in-item-row { display: grid; grid-template-columns: 22px minmax(190px, 2.2fr) 86px 92px minmax(110px, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.in-item-row:last-child { border-bottom: none; }
.in-item-row select, .in-item-row input { width: 100%; min-width: 0; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.in-item-mat-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.in-item-mat-wrap > .sel-combo-inline { flex: 0 0 auto; min-width: 0; }
.in-item-row .sel-combo-inline { min-width: 0; }
/* 选中物料后补充显示规格 / 单位 / 类别，不展开下拉也能确认选对了物料 */
.in-item-mat-info { font-size: 11px; line-height: 1.4; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.in-item-mat-info.hidden { display: none; }
.in-items-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.in-items-sum { font-size: 12px; color: var(--text-muted); }
.in-items-sum b { color: var(--text); }
.form-errors { margin-top: 8px; padding: 9px 12px; border: 1px solid #fecaca; background: #fef2f2; color: #b91c1c; border-radius: 6px; font-size: 12px; line-height: 1.6; }
.form-errors.hidden { display: none; }

/* BOM 物料明细行：每行独立关键词搜索框 */
.bom-mat-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bom-item-row .bom-mat-search { padding: 5px 9px; font-size: 12px; border: 1px dashed var(--border); border-radius: 6px; }
.bom-mat-search::placeholder { color: #94a3b8; }
.bom-mat-hint { font-size: 11px; line-height: 1.3; color: #b45309; }
.bom-mat-hint.hidden { display: none; }

/* BOM 物料明细行 */
.bom-item-row { display: grid; grid-template-columns: 22px minmax(180px, 1fr) 110px auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.bom-item-row:last-child { border-bottom: none; }
.bom-item-row select, .bom-item-row input { width: 100%; min-width: 0; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.bom-idx { font-size: 12px; color: var(--text-muted); text-align: center; }
.bom-empty { padding: 14px 0; text-align: center; font-size: 13px; color: var(--text-muted); }
.bom-hint { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
.bom-errors { margin-top: 12px; padding: 9px 12px; border: 1px solid #fecaca; background: #fef2f2; color: #b91c1c; border-radius: 6px; font-size: 12px; line-height: 1.6; white-space: pre-line; }
.bom-errors.hidden { display: none; }
#bom-save-btn:disabled { opacity: .6; cursor: wait; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: #fff; border-radius: 12px; z-index: 101; width: 640px; max-width: 92vw; max-height: 88vh; overflow-y: auto; }
.modal.wide { width: 900px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* 工具栏 */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }
.toolbar .toolbar-desc { font-size: 13px; color: var(--text-muted); }
.toolbar input, .toolbar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

/* 台账筛选栏（库存台账 / 批次库存台账） */
.filter-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.filter-bar input[type="number"] { width: 112px; }
.filter-bar input[type="date"] { width: 150px; }
.filter-bar .toolbar-desc { white-space: nowrap; font-weight: 500; }
/* 盘点单筛选栏关键词框占更宽，便于输入长关键词 */
.filter-bar #st-search { flex: 1 1 260px; min-width: 240px; }

/* 按钮行（导入导出卡片内） */
.btn-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* 看板图表 */
.chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.chart-box { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.chart-box h4 { margin-bottom: 12px; font-size: 14px; }
.bar { height: 18px; background: #f1f5f9; border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .4s; }
.bar-fill.danger { background: var(--danger); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.success { background: var(--success); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* 对账单 */
.recon-table td, .recon-table th { border: 1px solid var(--border) !important; }
.print-header { display: none; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 260px;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 2px 0 16px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4);
    z-index: 40; opacity: 0; pointer-events: none; transition: opacity .25s ease;
  }
  .sidebar-mask.show { opacity: 1; pointer-events: auto; }
  .menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border: none; background: transparent;
    font-size: 22px; color: var(--text); cursor: pointer; border-radius: 8px;
    flex-shrink: 0; -webkit-tap-highlight-color: transparent;
  }
  .menu-toggle:active { background: #f1f5f9; }
  .topbar { padding: 0 12px; height: 52px; }
  .topbar-title { font-size: 16px; }
  .content { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 20px; }
  .card-header { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .btn { padding: 9px 14px; min-height: 40px; }
  .btn-sm { padding: 6px 10px; min-height: 32px; }
  .toolbar { gap: 8px; }
  .toolbar input, .toolbar select { padding: 10px 12px; font-size: 15px; }
  .filter-bar input[type="text"], .filter-bar select { flex: 1 1 45%; min-width: 0; }
  .filter-bar .sel-combo-inline { flex: 1 1 45%; min-width: 0; }
  .filter-bar .sel-combo-inline > input.sel-generic-search { width: 100%; min-width: 0; font-size: 15px; padding: 10px 12px; }
  .filter-bar #st-search { flex: 1 1 100%; min-width: 0; }
  .filter-bar input[type="number"], .filter-bar input[type="date"] { flex: 1 1 45%; width: auto; }
  .filter-bar .toolbar-desc { width: 100%; white-space: normal; }
  .pk-item-row { grid-template-columns: 22px 1fr 1fr; }
  .pk-item-row .sel-combo-inline, .pk-item-row .pk-item-batch, .pk-item-row .pk-item-info { grid-column: 2 / 4; }
  .pk-item-row .pk-item-qty { grid-column: 2 / 3; }
  .pk-item-row .btn { grid-column: 3 / 4; justify-self: end; }
  .st-item-row { grid-template-columns: 22px 1fr; gap: 6px; align-items: start; }
  .st-item-row > * { grid-column: 2 / 3; }
  .st-item-row .pk-idx { grid-column: 1 / 2; grid-row: 1 / span 6; padding-top: 9px; }
  .st-item-book, .st-item-diff { text-align: left; }
  .st-item-row .btn { justify-self: end; }
  .st-item-row select, .st-item-row input { font-size: 15px; padding: 9px 10px; }
  .in-item-row { grid-template-columns: 22px 1fr; gap: 6px; align-items: start; }
  .in-item-row > * { grid-column: 2 / 3; }
  .in-item-row .pk-idx { grid-column: 1 / 2; grid-row: 1 / span 5; padding-top: 9px; }
  .in-item-row .btn { justify-self: end; }
  .in-item-row select, .in-item-row input { font-size: 15px; padding: 9px 10px; }
  .in-items-box { max-height: 46vh; }
  .bom-item-row { grid-template-columns: 22px 1fr 1fr; gap: 6px; }
  .bom-item-row .bom-mat-wrap { grid-column: 2 / 4; }
  .bom-item-row .bom-qty { grid-column: 2 / 3; }
  .bom-item-row .btn { grid-column: 3 / 4; justify-self: end; }
  .bom-item-row select, .bom-item-row input { font-size: 15px; padding: 9px 10px; }
  .bom-item-row .bom-mat-search { font-size: 14px; padding: 8px 10px; }
  .bom-item-row .bom-idx { grid-row: 1 / span 3; padding-top: 9px; }
  .sel-panel, .bom-mat-wrap .sel-panel { min-width: 0; width: 100%; max-height: 210px; }
  .sel-option { padding: 10px 12px; }
  .sel-option-main { font-size: 14px; }
  .sel-option-sub { font-size: 12px; }
  .sel-current { font-size: 13px; }
  .form-field input, .form-field select, .form-field textarea { font-size: 15px; padding: 10px 12px; }
  .modal { width: 100%; max-width: 100vw; height: 100%; max-height: 100dvh; border-radius: 0; }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .login-view, .auth-wrap { padding: 16px; }
  .login-card { padding: 28px 22px; }
}

@media (min-width: 769px) {
  .menu-toggle { display: none; }
  .sidebar { position: relative; }
}

/* 数据备份 */
.backup-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.backup-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 20px; text-align: center; background: #fbfcfe; }
.backup-icon { font-size: 36px; margin-bottom: 12px; }
.backup-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.backup-desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 16px; min-height: 44px; }
.backup-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.backup-tip { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius); padding: 14px 16px; font-size: 13px; line-height: 1.7; color: #1e40af; }
@media (max-width: 768px) {
  .backup-grid { grid-template-columns: 1fr; }
}

/* 打印 */
@media print {
  .sidebar, .sidebar-mask, .menu-toggle, .topbar, .toolbar, .btn, .modal-mask, .modal { display: none !important; }
  .app-wrap, .main, .content { height: auto; overflow: visible; display: block; }
  .print-header { display: block; text-align: center; font-size: 18px; font-weight: 700; margin-bottom: 12px; }
  .card { border: 1px solid #000; }
}

/* 单据查询「全部单据」汇总视图 */
.dq-all-summary { padding: 10px 4px 12px; color: var(--text-muted); font-size: 13px; line-height: 1.7; }
.dq-all-summary b { color: var(--text); font-size: 15px; }
.dq-all-table td:nth-child(2) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dq-all-table th.num, .dq-all-table td.num { text-align: right; }

/* 角色权限 · 账号与角色管理 */
.acc-table td { vertical-align: middle; }
.acc-table td.actions { white-space: nowrap; }
.acc-table .btn-sm { padding: 3px 9px; font-size: 12px; }
.acc-role-sel { padding: 4px 8px; font-size: 13px; min-width: 112px; border-radius: 6px; }
.acc-role-sel:disabled { opacity: .65; cursor: not-allowed; }

/* ===== 角色权限：顶部角色提示条 / 顶栏角色标签 ===== */
.role-bar {
  margin: 0 24px 12px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid transparent;
}
.role-bar-admin  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.role-bar-user   { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.role-bar-viewer { background: #f8fafc; border-color: #e2e8f0; color: #475569; }
.chip-role {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(148, 163, 184, .25);
  color: inherit;
}
@media (max-width: 768px) {
  .role-bar { margin: 0 12px 10px; font-size: 12px; }
}
/* 权限矩阵表格 */
.perm-table td:first-child { white-space: nowrap; font-weight: 600; }
.perm-table .yes { color: #16a34a; font-weight: 600; }
.perm-table .no  { color: #cbd5e1; }
