/* styles.css — 盲盘系统 SPA 样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #1a365d;
  --primary-light: #2c5282;
  --accent: #38a169;
  --danger: #e53e3e;
  --warning: #d69e2e;
  --bg: #f7fafc;
  --card: #ffffff;
  --text: #2d3748;
  --text-light: #718096;
  --border: #e2e8f0;
}
body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
#app { min-height: 100vh; }
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--text-light);
}
/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 24px;
}
.login-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.login-card h1 {
  font-size: 22px;
  color: var(--primary);
  margin-bottom: 8px;
  text-align: center;
}
.login-card .sub {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 24px;
  text-align: center;
}
.login-form .field { margin-bottom: 16px; }
.login-form label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 4px;
}
.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.login-form input:focus { border-color: var(--primary-light); }
.login-form .btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
}
.login-form .btn:hover { background: var(--primary-light); }
.login-form .btn:disabled { background: var(--text-light); cursor: not-allowed; }
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
  min-height: 20px;
}
/* ===== App Layout ===== */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-header {
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header .title { font-size: 16px; font-weight: 600; }
.app-header .user-info { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.app-header .user-info .role {
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}
.app-header .logout-btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.app-header .logout-btn:hover { background: rgba(255,255,255,0.25); }
.app-nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  position: sticky;
  top: 52px;
  z-index: 9;
}
.app-nav .nav-item {
  padding: 12px 16px;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.app-nav .nav-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}
.app-nav .nav-item:hover { color: var(--primary); }
.app-main { flex: 1; padding: 20px; max-width: 1200px; margin: 0 auto; width: 100%; }
/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--primary);
}
/* ===== Buttons ===== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-success { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: #edf2f7; color: var(--text); }
.btn-secondary:hover { background: #e2e8f0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* v3.5 三锁权限: 锁定状态视觉 */
.btn-edit-row:disabled { background:#e2e8f0; color:#a0aec0; border:1px dashed #cbd5e0; }
.btn-edit-row:disabled:hover { background:#e2e8f0; }
.data-table tr.editing { background:#fffbea; }
.data-table tr.editing input { padding:4px 6px; border:1px solid #90cdf4; border-radius:4px; font-size:13px; }
/* ===== Forms ===== */
.form-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.form-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 120px; }
.form-field label { font-size: 12px; color: var(--text-light); }
.form-field input, .form-field select, .form-field textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}
.form-field input:focus, .form-field select:focus { border-color: var(--primary-light); }
/* ===== Tables ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table th {
  background: #edf2f7;
  font-weight: 600;
  color: var(--text);
}
.data-table tr:hover { background: #f7fafc; }
/* ===== Dict Search ===== */
.dict-results { max-height: 300px; overflow-y: auto; margin-top: 8px; }
.dict-item {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dict-item:hover { background: #edf2f7; border-color: var(--primary-light); }
.dict-item .code { font-weight: 600; color: var(--primary); }
.dict-item .name { flex: 1; margin-left: 12px; }
/* ===== INV Items ===== */
.inv-items { margin-top: 12px; }
.inv-row {
  display: grid;
  grid-template-columns: 30px 1fr 1fr 80px 120px 60px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  background: #f7fafc;
}
.inv-row .idx {
  width: 24px; height: 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.inv-row input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}
.inv-row .remove-btn {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 28px; height: 28px;
  cursor: pointer;
}
/* 编码输入框容器 (放建议下拉) */
.inv-row .code-cell {
  position: relative;
}
.code-suggest {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--primary);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: 100;
  max-height: 260px;
  overflow-y: auto;
}
.code-suggest-item {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}
.code-suggest-item:last-child { border-bottom: none; }
.code-suggest-item:hover { background: #ebf8ff; }
.code-suggest-item .cs-code { font-weight: 600; color: var(--primary); flex-shrink: 0; }
.code-suggest-item .cs-name { color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 复盘扫码锁定行 (高亮 + 左侧蓝条) */
.inv-row.recount-locked {
  background: #ebf8ff !important;
  border-left: 4px solid var(--primary);
  box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.15);
  position: relative;
}
.inv-row.recount-locked .idx {
  background: #3182ce !important;
  color: #fff !important;
  font-weight: 700;
}
.inv-row.recount-locked::before {
  content: '🔒 扫码锁定';
  position: absolute;
  top: -10px; right: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}
/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 70px;
  right: 20px;
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--accent); }
.toast.error { background: var(--danger); }
/* ===== Recount Judgement Buttons (v3.6) ===== */
.judg-cell { display: flex; gap: 4px; align-items: center; }
.judg-btn {
  width: 36px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.judg-btn:hover { border-color: var(--primary); }
.judg-btn.accurate.active {
  background: #c6f6d5; border-color: #38a169; color: #22543d;
}
.judg-btn.wrong.active {
  background: #fed7d7; border-color: #e53e3e; color: #742a2a;
}
/* v3.6.7.2: 补录按钮 (⊕) 选中态 */
.judg-btn.recount-add.active {
  background: #f6ad55; border-color: #9c4221; color: #fff;
}
/* v3.6.7.2: 补录行背景 */
.inv-row.judg-recount-add {
  background: #fffaf0 !important;
  border-color: #f6ad55 !important;
}
/* 标✗行高亮 + 红框 */
.inv-row.judg-wrong {
  background: #fff5f5 !important;
  border-color: #fc8181 !important;
}
.inv-row.judg-accurate {
  background: #f0fff4 !important;
  border-color: #9ae6b4 !important;
}
/* 缺更正错误态 */
.inv-row.judg-error {
  background: #fff5f5 !important;
  border: 2px solid #e53e3e !important;
  animation: shake 0.4s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
/* 字典弹层 (更正用) */
.dict-picker {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
}
.dict-picker .dp-search {
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  font-size: 13px;
  outline: none;
  background: #f7fafc;
}
.dict-picker .dp-item {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f4f8;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.dict-picker .dp-item:hover { background: #ebf8ff; }
.dict-picker .dp-item .dp-code { font-weight: 600; color: var(--primary); min-width: 100px; }
.dict-picker .dp-item .dp-name { flex: 1; color: var(--text); }
.dict-picker .dp-empty { padding: 12px; text-align: center; color: #a0aec0; font-size: 12px; }
/* ===== Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-card .value { font-size: 24px; font-weight: 600; color: var(--primary); }
.stat-card .label { font-size: 12px; color: var(--text-light); margin-top: 4px; }
/* ===== Print View ===== */
@media print {
  .app-header, .app-nav, .no-print { display: none !important; }
  .app-main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
/* ===== Label Paper (打印小票 - 按参考图) ===== */
.print-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #edf2f7;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.print-toolbar > .btn { flex-shrink: 0; }
.lbl-chip {
  flex: 1;
  min-width: 200px;
  text-align: center;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #2d3748;
  font-weight: 500;
}
.lbl-chip:hover { background: #f7fafc; border-color: #1a365d; }
.print-meta {
  padding: 0 8px 14px;
  color: #718096;
  font-size: 13px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}
.print-meta-inv {
  font-weight: 600;
  color: #1a365d;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
}
.print-meta-sep { margin: 0 6px; color: #cbd5e0; }
.lbl-picker {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 100;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 480px;
}
.lbl-opt {
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #2d3748;
}
.lbl-opt:hover { background: #edf2f7; border-color: #1a365d; }
.lbl-opt.selected { background: #1a365d; color: #fff; border-color: #1a365d; font-weight: 500; }
.lbl-opt.custom { background: #f7fafc; }
.label-grid {
  display: flex;
  flex-direction: column;
  gap: 4mm;
  padding: 4mm;
  max-width: calc(var(--lw, 80mm) + 8mm);
  margin: 0 auto;
}
@media print {
  .label-grid { gap: 0; padding: 0; max-width: none; }
  .app-main { padding: 0 !important; max-width: none !important; }
}
.label-card {
  width: var(--lw, 80mm);
  height: var(--lh, 50mm);
  background: #fff;
  border: 1px dashed #999;
  display: grid;
  grid-template-columns: 1fr 28mm;
  padding: 2mm 2.5mm;
  box-sizing: border-box;
  page-break-inside: avoid;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}
@media print {
  .label-card {
    border: none;
    border-bottom: 1px dashed #000;
    page-break-after: always;
    break-after: page;
  }
  .label-card:last-child { page-break-after: auto; border-bottom: none; }
}
.label-left {
  display: flex;
  flex-direction: column;
  gap: 0.6mm;
  min-width: 0;
  padding-right: 1.5mm;
  justify-content: space-between;
}
.label-row {
  display: flex;
  align-items: baseline;
  gap: 1.5mm;
  font-size: 7.5pt;
  line-height: 1.25;
}
.label-row.small {
  font-size: 6.5pt;
  color: #4a5568;
}
.label-row.sep {
  height: 1mm;
  border-top: 1px solid #e2e8f0;
  margin: 0.5mm 0 0.3mm;
}
.label-key {
  color: #a0aec0;
  min-width: 7mm;
  flex-shrink: 0;
  font-size: 6.5pt;
}
.label-row.small .label-key { font-size: 6pt; }
.label-val { color: #2d3748; min-width: 0; word-break: break-all; }
.label-val.inv-code {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 6.5pt;
  color: #4a5568;
  letter-spacing: -0.3px;
}
.label-val.seq-num { font-weight: 700; color: #1a365d; font-size: 8pt; }
.label-val.item-code {
  font-weight: 600;
  color: #1a365d;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 7.5pt;
  letter-spacing: -0.3px;
}
.label-val.item-name { font-weight: 500; color: #2d3748; }
.label-val.qty-num {
  font-weight: 700;
  color: #c53030;
  font-size: 13pt;
  line-height: 1;
}
.label-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border-left: 1px dashed #cbd5e0;
  padding-left: 1.5mm;
  min-width: 0;
}
.label-qr {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  padding: 0.5mm 0;
}
.label-qr svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}
.label-qr-hint {
  font-size: 5.5pt;
  color: #a0aec0;
  text-align: center;
  margin-top: 0.5mm;
  white-space: nowrap;
}
@media print {
  .label-val.qty-num { color: #000; }
  .label-val.item-code, .label-val.seq-num, .label-row .label-key { color: #000; }
  .label-val.inv-code, .label-row.small .label-key, .label-row.small .label-val { color: #333; }
  .label-right { border-left-color: #666; }
  .label-qr-hint { color: #555; }
}

/* v3.6: 准确率颜色 (dashboard person_stats 表格) */
.acc-gray { color: #a0aec0; font-weight: 600; }
.acc-red { color: #e53e3e; font-weight: 700; }
.acc-yellow { color: #d69e2e; font-weight: 700; }
.acc-green { color: #38a169; font-weight: 700; }
.acc-red-cell { background: #fff5f5; }
.acc-yellow-cell { background: #fffbea; }
.acc-green-cell { background: #f0fff4; }
.acc-gray-cell { background: #f7fafc; }
.person-row:hover { background: #ebf8ff !important; transition: background 0.15s; }
