:root {
  --bg: #f3f5f2;
  --panel: #ffffff;
  --ink: #23312a;
  --muted: #6d7d74;
  --line: #dde4df;
  --accent: #2e6e4e;
  --accent-ink: #ffffff;
  --danger: #b3402e;
  --danger-bg: #fbeae6;
  --warn-bg: #fdf3d8;
  --chip-bg: #eaf0ec;
  --mono: Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}

.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 20px;
}
.topbar .brand { font-weight: 700; font-size: 17px; }
.topbar nav { display: flex; gap: 4px; }
.topbar a {
  color: var(--accent-ink); text-decoration: none;
  padding: 6px 14px; border-radius: 6px; opacity: .85;
}
.topbar a.on, .topbar a:hover { background: rgba(255,255,255,.18); opacity: 1; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 18px 20px; margin-bottom: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.panel h2 small { color: var(--muted); font-weight: 400; margin-left: 8px; }

.flash {
  background: var(--warn-bg); border: 1px solid #e8d49a;
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
}

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
input, select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  padding: 9px 16px; border: 1px solid transparent; border-radius: 7px;
  font-size: 14px; font-family: inherit; cursor: pointer;
  background: var(--chip-bg); color: var(--ink); text-decoration: none; display: inline-block;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.done { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn:hover { filter: brightness(1.08); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
td { font-size: 15px; font-variant-numeric: tabular-nums; }
td form { display: inline-block; margin: 0; }
td.actions { white-space: nowrap; }
tr.inactive td { opacity: .55; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.95em; }
td.mono, th.mono { font-size: 14.5px; }
.combo-item { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  background: #fbfcfa;
}
.card.overtime { background: var(--danger-bg); border-color: var(--danger); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.card-head strong { font-size: 16px; }
.card-head .muted { font-size: 13px; }

.current { display: flex; flex-direction: column; gap: 8px; }
.current .muted { margin-left: 8px; }
.timer { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card.overtime .timer { color: var(--danger); }
.row-actions { display: flex; gap: 8px; }

.idle { color: var(--muted); padding: 12px 0; }
.idle.warn { color: var(--danger); font-weight: 600; }

.queued { margin-top: 10px; font-size: 13px; color: var(--muted); }
.chip {
  display: inline-block; background: var(--chip-bg); border-radius: 5px;
  padding: 2px 8px; margin: 2px 2px 2px 0; font-size: 14px;
  color: var(--ink); text-decoration: none;
}
a.chip:hover { outline: 1px solid var(--accent); }

.edit-form { display: flex; flex-direction: column; gap: 12px; }
.edit-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.edit-form input { font-size: 15px; }
.warn-chip { background: var(--warn-bg); }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }

.detail-block { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.detail-block summary { cursor: pointer; padding: 4px 0; }
.detail-block table { margin-top: 8px; }

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  main { padding: 12px 8px 40px; }
  .panel { padding: 14px; }
}

/* ---- PDA 员工端 ---- */
.pda-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pda-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 26px 10px; border-radius: 14px; text-decoration: none; color: inherit;
  background: var(--chip-bg); border: 2px solid var(--accent);
}
.pda-tile .pda-icon { font-size: 44px; }
.pda-tile .pda-title { font-size: 22px; font-weight: 700; }
.pda-tile.disabled { border-style: dashed; opacity: .55; }
@media (max-width: 480px) { .pda-menu { grid-template-columns: 1fr; } }
/* PDA 顶栏：两行布局——第一行 品牌 | 语言 | 退出，第二行 两个功能页签各占一半；任何屏宽都不横向溢出 */
html, body.pda { max-width: 100%; overflow-x: hidden; }
body.pda .topbar { flex-wrap: wrap; gap: 6px 6px; padding: 8px 8px; }
body.pda .topbar .brand { font-size: 15px; white-space: nowrap; }
body.pda .topbar .lang-switch { margin-left: auto; margin-right: 0; }
body.pda .topbar .lang-switch a { padding: 5px 6px; font-size: 13px; }
body.pda .topbar form { margin: 0; }
body.pda .topbar form .btn { padding: 6px 9px; white-space: nowrap; font-size: 14px; }
body.pda .topbar nav { order: 10; flex-basis: 100%; display: flex; gap: 6px; }
body.pda .topbar nav a { flex: 1; text-align: center; padding: 8px 4px; white-space: nowrap; }
body.pda main { padding: 12px; }
body.pda .panel { padding: 14px 12px; overflow-x: auto; }
body.pda .inline-form input { min-width: 0 !important; flex: 1 1 140px; max-width: 100%; }
body.pda #qty-input { width: 120px !important; flex: 0 0 auto; }
body.pda table { width: 100%; }

/* ---- 管理端首页 / 模块 ---- */
.topbar .brand { color: #fff; text-decoration: none; }
.topbar .module-name { color: rgba(255,255,255,.75); font-size: 14px; padding: 0 6px; border-left: 1px solid rgba(255,255,255,.3); margin-left: 4px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.home-panel { max-width: 760px; margin: 12vh auto 0; padding: 36px 40px 28px; text-align: center; }
.home-panel h2 { justify-content: center; font-size: 22px; margin-bottom: 22px; }
.home-note { margin-top: 22px; }
.module-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 34px 20px 28px; border-radius: 12px; text-decoration: none; color: inherit;
  background: var(--chip-bg); border: 2px solid var(--line);
}
.module-tile:hover { border-color: var(--accent); }
.module-tile .module-icon { font-size: 44px; }
.module-tile .module-title { font-size: 20px; font-weight: 700; }

/* ---- 入库单明细行编辑器 ---- */
.lines-table { width: 100%; }
.lines-table td { padding: 4px 6px; }
.lines-table input { width: 100%; font-size: 15px; }
.lines-table td.idx, .lines-table td.total { text-align: center; color: var(--muted); }
.chip.small { font-size: 12px; white-space: nowrap; }
.lang-switch { display: flex; gap: 2px; margin-right: 8px; }
.lang-switch a { color: rgba(255,255,255,.7); text-decoration: none; font-size: 13px; padding: 4px 7px; border-radius: 6px; }
.lang-switch a.on { background: rgba(255,255,255,.22); color: #fff; font-weight: 700; }

/* 英/西语文案比中文长：员工端整体缩一号字，长词允许折行，避免溢出 */
body.pda.lang-en, body.pda.lang-es { font-size: 14px; }
body.pda.lang-en #msg, body.pda.lang-es #msg, body.pda.lang-en #task-box, body.pda.lang-es #task-box { overflow-wrap: anywhere; }
body.pda table th, body.pda table td.mono { white-space: nowrap; }   /* 表头/编码不拆词，过宽时在卡片内横向滚 */
body.pda.lang-en .panel h2, body.pda.lang-es .panel h2 { font-size: 16px; }
body.pda.lang-en #step-label, body.pda.lang-es #step-label { font-size: 17px !important; line-height: 1.25; }
body.pda.lang-en #task-box, body.pda.lang-es #task-box { font-size: 14px !important; }
body.pda.lang-en #msg, body.pda.lang-es #msg { font-size: 14px !important; }
body.pda.lang-en #scan-input, body.pda.lang-es #scan-input { font-size: 17px !important; }
body.pda.lang-en #qty-input, body.pda.lang-es #qty-input { font-size: 20px !important; }
body.pda.lang-en #confirm-btn, body.pda.lang-es #confirm-btn { font-size: 15px !important; padding: 9px 12px; }
body.pda.lang-en .btn, body.pda.lang-es .btn { font-size: 14px; padding: 8px 12px; }
body.pda.lang-en .topbar nav a, body.pda.lang-es .topbar nav a { font-size: 14px; }
body.pda.lang-en .pda-tile .pda-title, body.pda.lang-es .pda-tile .pda-title { font-size: 19px; }
body.pda.lang-en .muted.small, body.pda.lang-es .muted.small { font-size: 12px; }
body.pda.lang-en label, body.pda.lang-es label { font-size: 13px; }
body.pda.lang-en table th, body.pda.lang-en table td, body.pda.lang-es table th, body.pda.lang-es table td { font-size: 13px; padding: 6px 6px; }
body.pda.lang-en .row-actions, body.pda.lang-es .row-actions { flex-wrap: wrap; }

/* 客户编号选择框（输入可搜索 + ▾ 下拉 + 新增） */
.combo { position: relative; }
.combo-box { display: flex; align-items: stretch; }
.combo-box input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.combo-toggle {
  border: 1px solid var(--line); border-left: 0; border-radius: 0 7px 7px 0; background: var(--chip-bg);
  color: var(--muted); font-size: 18px; line-height: 1; padding: 0 12px; cursor: pointer;
}
.combo-toggle:hover { color: var(--ink); }
.combo-menu {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10); max-height: 260px; overflow-y: auto; font-size: 15px;
}
.combo-item { padding: 9px 12px; cursor: pointer; color: var(--ink); font-family: var(--mono); }
.combo-item:hover, .combo-item.active { background: var(--chip-bg); }
.combo-item.combo-add { font-family: inherit; color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); }
.combo-empty { padding: 9px 12px; color: var(--muted); font-size: 13px; }

/* Excel 导入进度条 */
.excel-import { display: flex; flex-direction: column; gap: 6px; }
.progress { height: 8px; background: var(--chip-bg); border-radius: 4px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress .bar.busy { background: repeating-linear-gradient(45deg, var(--accent) 0 10px, #4f9070 10px 20px); background-size: 28px 28px; animation: bar-move 1s linear infinite; }
.progress .bar.done { background: var(--accent); }
.progress .bar.err { background: var(--danger); }
@keyframes bar-move { from { background-position: 0 0; } to { background-position: 28px 0; } }
#excel-status.ok { color: var(--ink); }
#excel-status.danger { color: var(--danger); }
.lines-table input.need-fill { background: var(--warn-bg); }

/* 二级页签（批次库存 / 设置） */
.subnav { display: flex; gap: 4px; margin: -4px 0 14px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 15px; }
.subnav a:hover { color: var(--ink); }
.subnav a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.filter-bar { margin-bottom: 12px; }
.filter-bar input { width: 160px; }
.filter-bar input[type=date] { width: 150px; }

/* 筛选栏里的下拉框 */
.filter-bar .combo { width: 170px; }
.filter-bar .combo input { width: 100%; }
.combo-box input { font-size: 14px; }
.order-links a { display: inline-block; margin: 1px 6px 1px 0; padding: 2px 8px; border-radius: 5px; background: var(--chip-bg); color: var(--accent); text-decoration: none; font-size: 14px; font-family: var(--mono); }
.order-links a:hover { outline: 1px solid var(--accent); }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 10px; font-size: 14px; color: var(--muted); }

/* 效率报表 */
.panel h3 { margin: 6px 0 10px; font-size: 15.5px; }
.panel h3 small { font-weight: 400; margin-left: 8px; font-size: 13px; }
.eq-block { padding: 10px 12px; }
.eq-head { margin-bottom: 4px; }
.chip.best { background: var(--accent); color: #fff; }
.rel-good { color: var(--accent); font-weight: 600; }
.rel-low { color: var(--danger); font-weight: 600; }
tr.muted td { color: var(--muted); }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.kpis div { background: var(--chip-bg); border-radius: 8px; padding: 8px 16px; min-width: 96px; }
.kpis b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpis span { font-size: 12.5px; color: var(--muted); }
.btn.on { background: var(--chip-bg); border-color: var(--accent); color: var(--accent); }
.filter-bar select { font-size: 14px; }
.report-filter input[type=date] { width: 138px; }
.report-filter .combo { width: 130px; }

/* 效率报表：整体更宽、表格更松 */
main:has(.report-panel) { max-width: 1260px; }
table.roomy { table-layout: fixed; }
table.roomy th, table.roomy td { padding: 12px 12px; vertical-align: middle; }
table.roomy th { background: #f4f6f2; font-size: 13px; }
table.roomy th:first-child { border-radius: 6px 0 0 0; }
table.roomy th:last-child { border-radius: 0 6px 0 0; }
table.roomy td { font-size: 15px; }
table.roomy tr:nth-child(odd) td { background: #fbfbf9; }   /* 隔行浅底，横向好跟 */
table.roomy tr:hover td { background: #f1f5ee; }
table.roomy .num { text-align: center; }
table.roomy .w-name { width: 150px; }
table.roomy .w-rank { width: 100px; white-space: nowrap; }
table.roomy.even th:nth-child(2):not(.num) { width: 170px; }
table.roomy .fill { width: 30%; }
.eq-list { font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.eq-list span { display: inline-block; white-space: nowrap; margin: 1px 14px 1px 0; }
.eq-list b { color: var(--ink); font-weight: 600; }
.total-row td { color: var(--muted); border-top: 2px solid var(--line); background: #fff !important; }
.report-panel .kpis { margin: 8px 0 20px; gap: 14px; }
.report-panel .kpis div { padding: 10px 20px; min-width: 110px; }
th.num, td.num { text-align: center; }
