/* ============ 基础变量 ============ */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #e1e6ea;
  --primary: #1b5e20;
  --primary-d: #154a19;
  --primary-l: #e8f1ea;
  --text: #213547;
  --muted: #6b7785;
  --danger: #b71c1c;
  --warn: #8a6d00;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ============ 顶栏 ============ */
header.topbar {
  background: var(--primary);
  color: #fff;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
header.topbar .brand { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
header.topbar .user { font-size: 13px; display: flex; align-items: center; gap: 10px; }
header.topbar .user-name { font-weight: 600; }
header.topbar .user-role {
  background: rgba(255,255,255,0.18);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
}
header.topbar .logout {
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  transition: background 0.15s;
}
header.topbar .logout:hover { background: rgba(255,255,255,0.18); }

/* ============ 主体布局（左侧菜单 + 右侧内容） ============ */
.layout {
  display: flex;
  min-height: calc(100vh - 56px);
}
.content {
  flex: 1;
  padding: 18px 22px;
  overflow-x: auto;
  min-width: 0;
}
.content-narrow {
  flex: 1;
  padding: 18px 22px;
}

/* ============ 左侧菜单 ============ */
aside.sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 14px 0 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
aside.sidebar .menu-group { margin-bottom: 6px; }
aside.sidebar .group-title {
  font-size: 11px;
  color: var(--muted);
  padding: 14px 18px 6px;
  letter-spacing: 1px;
  font-weight: 600;
}
aside.sidebar a.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
aside.sidebar a.menu-item:hover { background: var(--primary-l); }
aside.sidebar a.menu-item.active {
  background: var(--primary-l);
  border-left-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
aside.sidebar a.menu-item .ic { font-size: 15px; width: 18px; text-align: center; }
aside.sidebar .sidebar-foot {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  background: #fafbfa;
}
aside.sidebar .sidebar-foot .foot-name {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  margin-top: 4px;
}

/* ============ 通用组件 ============ */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
h2.page-title { margin: 0 0 14px; font-size: 18px; color: var(--text); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
table.grid th { background: var(--primary-l); color: var(--primary); font-weight: 600; }
table.grid tr:nth-child(even) td { background: #fafbfa; }
table.grid tr:hover td { background: #f0f7f1; }
/* 卫生证等日期过期行（高亮） */
table.grid tr.row-expired td { background: #ffe5e5; color: #a33232; }
table.grid tr.row-expired:hover td { background: #ffd1d1; }

/* ============ Dashboard 证照到期提醒 banner ============ */
.reminder-banner {
  background: #fff8e1;
  border-left: 5px solid #f59e0b;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.12);
}
.reminder-banner .reminder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 15px;
  color: #92400e;
}
.reminder-banner .reminder-close {
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.reminder-banner .reminder-close:hover { background: #d97706; }
.reminder-banner .reminder-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.8;
}
.reminder-banner .reminder-item { padding: 2px 0; }
.reminder-banner .reminder-warn   { color: #b45309; }                    /* 30天内：橙色 */
.reminder-banner .reminder-urgent {
  color: #d32f2f;
  font-weight: 600;
}                                                                     /* 14天内：红色 */
.reminder-banner .reminder-expired {
  color: #b71c1c;
  font-weight: 700;
  background: #ffebee;
  padding: 2px 6px;
  border-radius: 4px;
  list-style-position: inside;
}                                                                     /* 已过期：深红+背景 */

/* ============ 入场登记页：业主自动联想 ============ */
.owner-ac-field { position: relative; }
.ac-dropdown {
  position: absolute;
  top: calc(100% - 2px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
}
.ac-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f0f3f5;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.ac-active {
  background: var(--primary-l);
}
.ac-item .ac-name { color: var(--text); }
.ac-item .ac-pinyin {
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 1px;
}

/* 入场登记：票据图片上传行 */
.upload-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.upload-row #ticketImagePreview {
  font-size: 12px;
  color: var(--primary);
  white-space: nowrap;
}
.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.12s;
}
.btn:hover { background: #f5f7f6; border-color: #c8d2cb; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--danger); border-color: #f0c4c4; }
.btn.danger:hover { background: #fbe9e9; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.block { display: block; width: 100%; padding: 11px; font-size: 15px; }
.auto-field input {
  background: #f4f6f8;
  color: var(--muted);
  cursor: not-allowed;
  max-width: 200px;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field-hint { font-size: 11px; color: var(--muted); font-weight: normal; margin-left: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,94,32,0.12);
}
/* 员工权限：身份联动的模块复选框 */
.perm-box { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.perm-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.perm-item input { width: auto; margin: 0; }
/* 列表中的权限标签 */
.perm-cell { line-height: 1.5; }
.perm-tag { display: inline-block; padding: 2px 8px; margin: 2px 4px 2px 0; border-radius: 10px;
  font-size: 12px; line-height: 1.6; background: #e8f0e8; color: #1b5e20; border: 1px solid #cfe3cf; }
.perm-tag.all { background: #e3eefc; color: #1a4fa0; border-color: #c5dcf5; }
.perm-tag.none { background: #fdeaea; color: #a33232; border-color: #f3c9c9; }
.flash { padding: 8px 12px; border-radius: 6px; margin-bottom: 10px; background: #fff8e1; border: 1px solid #f0e0a8; color: var(--warn); }
/* 「补XX边」入口进来但该猪边口已分配完 → 红字拦截（2026-09-21 现场反馈 1）。
   ⚠️ 故意**不复用 .flash**：套件里有用 `class="flash[^"]*">(内容)<` 抓 flash 文案的断言，
   复用会让「已分配完」的提示被误当成一条 flash 消息。 */
.fill-warn { padding: 9px 12px; border-radius: 6px; margin-bottom: 12px; background: #fdecea; border: 1px solid #f3c4bf; color: #b3261e; font-weight: 600; }
.muted { color: var(--muted); }
.row-actions a { margin-right: 6px; }
/* 预选称重列表：称重状态徽标 + 行底色区分 */
.ws-badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; line-height: 1.7; font-weight: 600; }
.ws-badge.ok { background: #e8f5e9; color: #1b7a2e; border: 1px solid #b7e0bd; }
.ws-badge.warn { background: #fff4e0; color: #a86a00; border: 1px solid #f3d9a8; }
tr.weighed td { background: #f4fbf4; }
tr.unweighed td { background: #fff; }

/* 待称重提示栏 */
.ps-pending-tip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 4px 0 12px; padding: 9px 14px;
  background: #fff8ec; border: 1px solid #f3d9a8; border-radius: 8px;
  color: #8a5a00; font-size: 14px;
}
.ps-pending-tip .tip-ic { font-size: 16px; }
.ps-pending-tip .tip-text { flex: 1; min-width: 160px; }
.ps-pending-tip .tip-text b { color: #a86a00; }
.ps-pending-tip .tip-text b.hot { color: #d23b00; }
.ps-pending-tip .tip-actions { margin-left: auto; }

/* 分页控件 */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.pager .pg {
  display: inline-block; padding: 5px 14px; border-radius: 6px;
  background: #fff; border: 1px solid #d9dde3; color: #2b6cb0;
  text-decoration: none; font-size: 13px;
}
.pager .pg:hover { background: #f0f6ff; }
.pager .pg.disabled { color: #b6bcc6; border-color: #eceef2; background: #fafbfc; cursor: not-allowed; }
.pager .pg-info { color: #6b7280; font-size: 13px; }

/* 详情页（查看预选） */
.detail { max-width: 720px; margin-top: 6px; }
.detail-row { display: flex; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.detail-row .k { width: 110px; color: var(--muted); flex: none; }
.detail-row .v { flex: 1; word-break: break-all; }
/* 统计表数值列右对齐 */
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 入场统计（summary） */
.lnk { color: #2b6cb0; text-decoration: none; }
.lnk:hover { text-decoration: underline; }
.date-range { font-size: 13px; color: #444; display: inline-flex; align-items: center; gap: 4px; }
.date-range input[type=date] { padding: 4px 6px; border: 1px solid #d9dde3; border-radius: 6px; }
/* 工具栏内的行内复选框（如入场统计「仅显示未宰杀完批次」） */
.ck-inline { font-size: 13px; color: #444; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.ck-inline input { width: auto; margin: 0; cursor: pointer; }
.stat-foot { margin-top: 10px; color: #6b7280; font-size: 13px; }
.crumb { margin: 0 0 8px; font-size: 13px; }
.sub-title { margin: 18px 0 8px; font-size: 15px; color: #1f2937; }
/* 预选统计：剩余未分配的半边高亮提示 */
table.grid td.warn-cell { color: #c05621; font-weight: 600; }

/* ============ 入场统计：边口分配分组表头 ============ */
table.grid th.th-group {
  text-align: center;
  border-bottom: 2px solid var(--line);
  background: #e8f3e9;
}
table.grid th.th-none, table.grid td.side-none { color: #b7791f; }      /* 未选：橙 */
table.grid th.th-soft, table.grid td.side-soft { color: #2b6cb0; }      /* 软边：蓝 */
table.grid th.th-hard, table.grid td.side-hard { color: #2f855a; }      /* 硬边：绿 */
table.grid th.th-whole, table.grid td.side-whole { color: #6b46c1; }    /* 整头：紫 */
/* 还有未选的 → 整行提示（配合数值列） */
table.grid td.side-none.side-hot { font-weight: 700; background: #fffaf0; }

/* 宰杀统计：KPI 卡片 + 折线图 + 合计行 */
.kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0 4px; }
.kpi {
  display: flex; flex-direction: column; gap: 1px; min-width: 116px;
  padding: 5px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc;
}
.kpi-k { font-size: 12px; color: var(--muted); }
.kpi-v { font-size: 18px; font-weight: 600; color: #1b5e20; line-height: 1.25; }
.chart-wrap { overflow-x: auto; margin: 6px 0 4px; }
.line-chart { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
table.grid.wide { font-size: 12px; }
table.grid.wide td, table.grid.wide th { white-space: nowrap; padding: 5px 6px; }
tr.sum-row td { font-weight: 600; background: #f4fbf4; border-top: 2px solid var(--line); }
td.num.pos { color: #c0392b; }
td.num.neg { color: #1b5e20; }

/* 宰杀统计：紧凑布局 —— 区间与 KPI 同行；趋势/业主/区域三栏并排 */
.kill-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 8px 0 2px; }
.kill-head .stat-foot { margin: 0; }
.kill-head .kpi-row { margin: 0; }
.kill-top {
  display: grid; gap: 14px; align-items: stretch; margin: 10px 0 6px;
  grid-template-columns: minmax(320px, 1fr) minmax(190px, 300px);
}
@media (max-width: 1180px) { .kill-top { grid-template-columns: 1fr; } }
.kill-box { min-width: 0; }
/* 右侧：业主表在上、区域表在下 */
.kill-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
/* 左侧：图表区高度撑满，与右侧两张表的合计高度一致 */
.kill-chart-box { display: flex; flex-direction: column; }
.kill-chart-box .chart-wrap { flex: 1 1 auto; min-height: 300px; }
.kill-chart-box svg.line-chart { display: block; margin: 0 auto; height: 100%; }
.kill-box .sub-title { margin: 0 0 6px; font-size: 14px; }
/* 小表限高内部滚动，避免长列表把下方批次表挤出首屏 */
.mini-scroll { max-height: 172px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
table.grid.mini { font-size: 12px; }
table.grid.mini th, table.grid.mini td { padding: 4px 8px; }
table.grid.mini thead th { position: sticky; top: 0; z-index: 1; box-shadow: inset 0 -1px 0 var(--line); }
.mini-scroll tr.sum-row td { position: sticky; bottom: 0; box-shadow: inset 0 1px 0 var(--line); }
/* 批次表限高 + 表头/合计行常驻，保证滚动时列名与合计始终可见 */
.batch-scroll { max-height: 56vh; overflow: auto; }
.batch-scroll table.grid.wide thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--line); }
.batch-scroll tr.sum-row td { position: sticky; bottom: 0; z-index: 1; box-shadow: inset 0 1px 0 var(--line); }

/* ============ 称重页 ============ */
.weigh-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.weight-big { font-size: 40px; font-weight: 700; color: var(--primary); }

/* ---- 称重页重排版（2026-09-12）：顶部称重条 + 3 列表单 + 底部记录 ---- */
/* 顶部：实时重量 / 称重按钮 / 状态，右侧同一排是 保存·调换·打印·取消 */
.weigh-topbar {
  display: flex; flex-wrap: wrap; gap: 12px 18px;
  align-items: center; justify-content: space-between;
  padding: 10px 14px; margin-bottom: 14px;
  background: #f7faf7; border: 1px solid var(--line); border-radius: 8px;
}
.weigh-topbar .wt-live { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.weigh-topbar .wt-label { font-size: 12px; color: var(--muted); }
.weigh-topbar .weight-big { font-size: 34px; line-height: 1.1; }
.weigh-topbar .wt-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.weigh-topbar .scale-status { margin-top: 0; }
/* 需填栏：每排 3 列 */
.form-grid.weigh-grid { grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.form-grid.weigh-grid > .field > label { margin-bottom: 3px; }
/* 记录表标题 + 底部保存条 */
.rec-title { margin: 22px 0 8px; }
.toolbar.weigh-savebar { margin-top: 14px; }
/* ---- 手动称重页：左右两栏，右上角两个提示框（未称重客户 / 未分配边口） ---- */
.weigh-cols { display: flex; gap: 16px; align-items: flex-start; }
.weigh-cols > .weigh-main { flex: 1 1 auto; min-width: 0; }
.weigh-aside { flex: 0 0 340px; width: 340px; display: flex; flex-direction: column;
  gap: 12px; position: sticky; top: 10px; }
.aside-box { border: 1px solid var(--line); border-radius: 8px; background: #fff;
  overflow: hidden; }
.aside-title { padding: 7px 12px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--line); background: #f7faf7;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.aside-hint { font-size: 11px; font-weight: 400; color: var(--muted); }
.aside-box.warn .aside-title { color: #a86a00; background: #fdefd8;
  border-bottom-color: #f0cfa0; }
.aside-scroll { max-height: 300px; overflow-y: auto; }
.aside-box table.grid { border: 0; width: 100%; }
.aside-box table.grid td, .aside-box table.grid th { font-size: 12.5px;
  white-space: nowrap; padding: 5px 9px; }
/* 未称重行：双击直达称重，避免双击时选中文本 */
.aside-box tbody tr.uw-row { cursor: pointer; user-select: none; }
.aside-box tbody tr.uw-row:hover { background: var(--primary-l); }
@media (max-width: 1150px) {
  .weigh-cols { flex-direction: column; }
  .weigh-aside { position: static; width: auto; flex: 1 1 auto;
    flex-direction: row; flex-wrap: wrap; }
  .weigh-aside > .aside-box { flex: 1 1 320px; }
}
@media (max-width: 900px) {
  .form-grid.weigh-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .form-grid.weigh-grid { grid-template-columns: 1fr; }
}
.record-win tbody tr { cursor: pointer; }
.record-win tbody tr:hover { background: var(--primary-l); }
/* 记录窗口列较多：时间/称重人不换行并略缩小，避免挤压 */
.record-win td, .record-win th { white-space: nowrap; font-size: 13px; }
.record-win td:nth-child(7) { font-variant-numeric: tabular-nums; }
/* 预选来源参考横幅 */
.ps-ref { background: #fff8e1; border: 1px solid #f0e0a8; color: #8a6d00;
  padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; line-height: 1.7; }
.ps-lock-hint { background: #e8f4ff; border: 1px solid #bcdcff; color: #1558a8;
  padding: 6px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 12px; }
/* 「仅报备」预选进入称重页时，业主/编号/边口**可改**（2026-09-26）——
   用暖色区别于上面的蓝色「锁定」提示，现场一眼知道这次是能改的。 */
.ps-edit-hint { background: #fff8e6; border-color: #ffe0a3; color: #8a5a00; }
/* 预选表单：猪编号 ↔ 业主 一致性提示 */
.pig-hint { margin-top: 4px; font-size: 12px; line-height: 1.5; min-height: 16px; }
.pig-hint.ok   { color: #2e7d32; }
.pig-hint.err  { color: #c62828; font-weight: 600; }
.pig-hint.warn { color: #ef6c00; }

/* 预选称重：业主/编号/客户/市场 锁定态只读显示 */
input.ro { background: #f2f2f2; color: #555; border: 1px solid #ddd;
  padding: 7px 9px; border-radius: 5px; cursor: not-allowed; }
/* 称重软件连接状态提示 */
.scale-status { display: inline-block; margin-top: 6px; padding: 3px 9px; border-radius: 4px;
  font-size: 12px; line-height: 1.6; }
.scale-status.pending { background: #f5f5f5; color: #888; border: 1px solid #e0e0e0; }
.scale-status.ok      { background: #e8f5e9; color: #1b5e20; border: 1px solid #b6dfbc; }
.scale-status.err     { background: #fdecea; color: #b71c1c; border: 1px solid #f3c2bd; }
/* 实重行：输入框 + 实时跟随开关（同一行右侧） */
.net-row { display: flex; gap: 8px; align-items: center; }
.net-row input { flex: 1; min-width: 0; }
/* 实时跟随开关 + 实重联动高亮 */
.follow-ck { display: inline-flex; align-items: center; gap: 4px; font-size: 13px;
  color: #444; user-select: none; cursor: pointer; white-space: nowrap; }
.follow-ck input { width: auto; margin: 0; cursor: pointer; }
input.live { background: #e8f5e9; border-color: #b6dfbc; color: #1b5e20; font-weight: 600; }

/* ============ 登录页（全屏沉浸式） ============ */
body.login-mode {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 45%, #4caf50 100%);
  background-attachment: fixed;
  position: relative;
  overflow: hidden;
}
body.login-mode::before,
body.login-mode::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
body.login-mode::before {
  width: 420px; height: 420px;
  top: -120px; right: -120px;
  background: rgba(255,255,255,0.08);
}
body.login-mode::after {
  width: 320px; height: 320px;
  bottom: -100px; left: -100px;
  background: rgba(255,255,255,0.06);
}
body.login-mode .topbar { display: none; }
body.login-mode .content-narrow { padding: 0; }

.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 4px 14px rgba(0,0,0,0.15);
  padding: 36px 36px 28px;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center;
  margin-bottom: 22px;
}
.login-logo .icon {
  font-size: 52px;
  display: block;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.login-logo h1 {
  margin: 0;
  font-size: 22px;
  color: var(--primary);
  font-weight: 700;
}
.login-logo .sub {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
}
.login-card .field { margin-bottom: 16px; }
.login-card .field label {
  display: block;
  font-size: 12px;
  color: #555;
  margin-bottom: 6px;
  font-weight: 500;
}
.login-card .field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d6dde2;
  border-radius: 8px;
  font-size: 14px;
  background: #fafbfa;
  transition: all 0.15s;
}
.login-card .field input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(27,94,32,0.12);
}
.login-card button.btn.primary {
  background: var(--primary);
  border: none;
  letter-spacing: 4px;
  font-weight: 600;
  margin-top: 6px;
  box-shadow: 0 4px 10px rgba(27,94,32,0.25);
}
.login-card button.btn.primary:hover {
  background: var(--primary-d);
  box-shadow: 0 6px 14px rgba(27,94,32,0.35);
  transform: translateY(-1px);
}
.login-card .hint {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.login-card .hint code {
  background: var(--primary-l);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: Consolas, "Courier New", monospace;
}
.login-wrap .copyright {
  margin-top: 18px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  letter-spacing: 1px;
}

/* ============ 客户登录页（橙色主题，与员工区分） ============ */
body.customer-login-mode {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #b94500 0%, #e65100 45%, #ff8a50 100%);
  background-attachment: fixed;
  position: relative;
  overflow: hidden;
}
body.customer-login-mode::before,
body.customer-login-mode::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
body.customer-login-mode::before {
  width: 420px; height: 420px;
  top: -120px; left: -120px;
  background: rgba(255,255,255,0.08);
}
body.customer-login-mode::after {
  width: 360px; height: 360px;
  bottom: -110px; right: -110px;
  background: rgba(255,255,255,0.06);
}
body.customer-login-mode .topbar { display: none; }
body.customer-login-mode .content-narrow { padding: 0; }
body.customer-login-mode .login-logo h1 { color: #b94500; }
body.customer-login-mode .login-card .field input:focus {
  border-color: #e65100;
  box-shadow: 0 0 0 3px rgba(230,81,0,0.12);
}
body.customer-login-mode .login-card button.btn.primary {
  background: #e65100;
  box-shadow: 0 4px 10px rgba(230,81,0,0.28);
}
body.customer-login-mode .login-card button.btn.primary:hover {
  background: #b94500;
  box-shadow: 0 6px 14px rgba(230,81,0,0.38);
  transform: translateY(-1px);
}
body.customer-login-mode .login-card .hint code {
  background: #fff1e6;
  color: #b94500;
}

/* 登录页底部切换链接（员工↔客户） */
.alt-link {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
}
.alt-link a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
}
.alt-link a:hover { color: var(--primary-d); }
body.customer-login-mode .alt-link a { color: #b94500; }
body.customer-login-mode .alt-link a:hover { color: #8a3300; }
.alt-link .sep { margin: 0 8px; opacity: .45; }
body.owner-login-mode .alt-link a { color: #2f7a2f; }
body.owner-login-mode .alt-link a:hover { color: #1f5c1f; }
body.owner-login-mode .login-logo .icon { color: #2f7a2f; }

/* ============ 响应式（窄屏折叠菜单） ============ */
@media (max-width: 760px) {
  aside.sidebar {
    width: 64px;
  }
  aside.sidebar .group-title,
  aside.sidebar .sidebar-foot,
  aside.sidebar a.menu-item .lb {
    display: none;
  }
  aside.sidebar a.menu-item {
    justify-content: center;
    padding: 12px 4px;
    border-left-width: 0;
    border-bottom: 2px solid transparent;
  }
  aside.sidebar a.menu-item.active {
    border-left-width: 0;
    border-bottom-color: var(--primary);
  }
  aside.sidebar a.menu-item .ic {
    font-size: 18px;
    width: auto;
  }
  .content { padding: 12px; }
  .weigh-layout { grid-template-columns: 1fr; }
  .login-card { padding: 28px 22px; }
}
/* ============ 下水管理 / 猪头管理 ============ */
.cell {
  padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px;
  font: inherit; background: #fff; color: inherit; outline: none;
}
.cell:focus { border-color: var(--primary); }
.cell.num { text-align: right; width: 80px; font-variant-numeric: tabular-nums; }
.cell.wide-note { width: 100%; min-width: 100px; }
.btn.danger { background: #fff; border-color: #f5c2c0; color: #c0392b; }
.btn.danger:hover { background: #fcecec; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 11px; vertical-align: middle; }
.badge.co { background: #e8f5e9; color: #1b5e20; margin-left: 4px; }
.muted { color: #6b7785; }
.small { font-size: 11px; margin-left: 4px; }
td.op { white-space: nowrap; }
td.op form { display: inline-block; }
.settings-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.settings-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #444; }
table.grid.wide td.wt, table.grid.wide td.tot, table.grid.wide td.set { font-variant-numeric: tabular-nums; }

/* 下水管理：同批次挨着 + 两种底色交替（A 浅蓝、B 浅绿） */
table.grid.wide tr.tr-batch-a td { background: #eef4fb; }
table.grid.wide tr.tr-batch-a:hover td { background: #e1ecf6; }
table.grid.wide tr.tr-batch-b td { background: #f0f8ef; }
table.grid.wide tr.tr-batch-b:hover td { background: #e3f1e0; }
/* 操作列里的 input 不能透出底色，与行同色 */
table.grid.wide tr.tr-batch-a td.op,
table.grid.wide tr.tr-batch-b td.op { background: inherit; }

/* ========== 预选管理：今日新增 + 未称重高亮 ========== */
/* 今日新增行（默认浅金黄） */
table.grid tr.row-today td { background: #fff7d6; }
table.grid tr.row-today:hover td { background: #ffefc4; }
/* 今日新增且仍未称重（更深橙色，提示待称重） */
table.grid tr.row-today.row-unweighed td { background: #ffe2bf; }
table.grid tr.row-today.row-unweighed:hover td { background: #ffd49a; }
/* 昨日及更早 + 未称重（柔和提示） */
table.grid tr.row-unweighed td { background: #fff5ea; }
table.grid tr.row-unweighed:hover td { background: #ffe7d2; }
/* 未称重单元格内的提示文字 */
.pending-cell { color: #c62828; font-weight: 700; letter-spacing: 1px; }
/* ---- 预选管理：状态分类标签页 ---- */
.tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 2px solid var(--line); margin-bottom: 12px;
}
.tabs .tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 13px; color: #4b5563;
  text-decoration: none; border: 1px solid transparent;
  border-bottom: none; border-radius: 6px 6px 0 0; margin-bottom: -2px;
}
.tabs .tab:hover { background: #f3f6f4; color: var(--primary); }
.tabs .tab.active {
  background: #fff; border-color: var(--line);
  border-bottom: 2px solid #fff; color: var(--primary); font-weight: 600;
}
.tabs .tab-n {
  display: inline-block; min-width: 18px; padding: 1px 6px;
  background: #eef2f0; color: #4b5563; border-radius: 9px;
  font-size: 11px; text-align: center; font-variant-numeric: tabular-nums;
}
.tabs .tab.active .tab-n { background: var(--primary); color: #fff; }
.tab-tip {
  background: #f7faf8; border-left: 3px solid var(--primary);
  padding: 8px 12px; margin-bottom: 10px; font-size: 12px; color: #4b5563;
  border-radius: 0 6px 6px 0;
}

/* ---- 预选管理：状态标签 + 缺失半边提示 ---- */
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; white-space: nowrap;
}
/* 预选称重列表的「仅报备」行内编辑框（2026-09-26 需求 2）：
   表格里嵌入的输入框要窄、紧凑，别把行撑高；宽度按内容类型给（业主名 / 编号）。 */
.inline-inp {
  width: 100%; min-width: 88px; box-sizing: border-box;
  padding: 2px 6px; font-size: 12px;
  border: 1px solid #d7dbe0; border-radius: 4px; background: #fff;
}
.inline-inp:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px rgba(58,125,88,.12); }
.pill-unselected { background: #fff4e0; color: #b7791f; border: 1px solid #f0d9a8; }
.pill-reported   { background: #eef2ff; color: #4c51bf; border: 1px solid #c7d2fe; }
.pill-incomplete { background: #fdeceb; color: #c0392b; border: 1px solid #f5c2c0; }
.pill-done       { background: #e8f5e9; color: #2f855a; border: 1px solid #bfe3c4; }
.pill-ok         { background: #e8f5e9; color: #2f855a; border: 1px solid #bfe3c4; }
.pill-warn       { background: #fff4e0; color: #b7791f; border: 1px solid #f0d9a8; }
.half-miss {
  display: inline-block; margin-left: 4px; padding: 0 5px;
  background: #fdeceb; color: #c0392b; border-radius: 4px; font-size: 11px;
}

/* ---- 称重页：同一编号 · 各边口已存重量一览 ---- */
.pig-sides td.num { font-variant-numeric: tabular-nums; }
.pig-sides td.num b { color: #2f855a; }

/* ---- 预选表单：联想输入框（客户/业主/猪编号）---- */
.ac-field { position: relative; }
.ac-field input[type=text] { width: 100%; }

/* ---- 2026-10-13：称重记录「筛选行」里的联想框 ----
   ⚠️ 踩过的坑：这里原来用 `<span class="owner-ac-field" style="display:inline-block">`
   包着输入框、又塞在一个 flex `<label>` 里。inline-block 的包裹盒**宽度只跟着
   输入框**（86px），而 .ac-dropdown 是 `position:absolute; left:0; right:0` ——
   在 flex 行里会被 label 的行盒撑开，实测下拉宽 **743px**、位置也飘到别的列下面。
   正解：外层用**块级**基准（.ac-field，position:relative），宽度自己定死，
   下拉 left/right:0 就恰好与输入框等宽、正下方对齐。 */
.rec-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-filter .fl { display: inline-flex; align-items: center; gap: 6px;
                  font-size: 12.5px; color: var(--muted); }
.rec-filter .ac-narrow { display: inline-block; position: relative; width: 120px; }
.rec-filter .ac-narrow > input[type=text] { width: 100%; }
.rec-filter .ac-narrow .ac-dropdown { min-width: 150px; }

/* ---- 预选统计：运费列 —— 本行所选边口适用的那一列，用「彩色文字」强调 ----
   注意：**不要给这两列设 background / border / box-shadow**。
   - 设 `background` 会被 `table.grid tr:nth-child(even) td`（特异度更高）盖掉，
     同一列就会变成「奇数行有底色、偶数行没底色」的棋盘，看着和别的格不统一；
   - 设 `box-shadow: inset` 会在正常 1px 网格线内侧再画一圈，像双边框。
   本工程统一强调手法：**只改 `color` / `font-weight`**，背景与边框交给 table.grid 自己管
   （与 .side-hard / .side-soft / .warn-cell 等一致）。 */
table.grid td.fr-hit { color: #2f855a; font-weight: 700; }

/* 颜色图例条 */
.ps-legend { display: flex; gap: 14px; align-items: center; margin-top: 10px; font-size: 12px; }
.ps-legend .lg { display: inline-block; width: 16px; height: 12px; border-radius: 3px; border: 1px solid #e5dcc8; vertical-align: middle; margin-right: 4px; }
.ps-legend .lg-today  { background: #fff7d6; }
.ps-legend .lg-pending { background: #ffe2bf; border-color: #f0c89a; }
.ps-legend .lg-done   { background: #fafbfa; border-color: #e1e6ea; }

/* ========== 预选称重（工作人员）：今日新增预选行高亮 ========== */
/* weighing 页 class 命名用的是 weighed / unweighed（无 row- 前缀），
   且前面已有 tr.weighed td / tr.unweighed td；用更高优先级的复合选择器覆盖 */
table.grid tr.row-today td { background: #fff7d6; }
table.grid tr.row-today:hover td { background: #ffefc4; }
/* 今日新增且未称重（更深橙，提示待称重） */
table.grid tr.row-today.unweighed td { background: #ffe2bf; }
table.grid tr.row-today.unweighed:hover td { background: #ffd49a; }
/* 今日新增且已称重（今日深绿，提示当日完成） */
table.grid tr.row-today.weighed td { background: #d8eed0; }
table.grid tr.row-today.weighed:hover td { background: #c9e8c0; }

/* ========== 预选称重列表：下水/猪头联动列展示 ========== */
table.grid td.byprod-cell { font-size: 12px; line-height: 1.5; padding: 4px 6px; white-space: nowrap; }
table.grid td.byprod-cell .byprod-line { display: block; }
table.grid td.byprod-cell .bp-buyer { color: #5a3b00; font-weight: 600; }
table.grid td.byprod-cell .bp-qty   { color: #4a4a4a; margin-left: 2px; }
table.grid td.byprod-cell .bp-price { color: #888; margin-left: 2px; }
table.grid td.byprod-cell .bp-total { color: #333; margin-left: 2px; font-variant-numeric: tabular-nums; }
table.grid td.byprod-cell .muted { color: #bba; }

/* ========== 称重表单：下水/猪头联动区块高亮 ========== */
.byprod-box {
  border: 1px solid #f0c89a;
  background: #fff8ec;
  border-radius: 8px;
  padding: 10px 14px 14px;
  margin: 6px 0 4px;
}
.byprod-box legend {
  font-size: 13px;
  font-weight: 600;
  color: #a86a00;
  padding: 0 6px;
  background: #fff;
  border: 1px solid #f0c89a;
  border-radius: 4px;
}
.byprod-box .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 760px) {
  .byprod-box .form-grid { grid-template-columns: 1fr; }
}

/* ========== 测试模式 banner (Test 账号独占) ========== */
.test-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 18px;
  background: linear-gradient(180deg, #ffe2b8 0%, #ffd28a 100%);
  border-bottom: 2px solid #f39c12;
  font-size: 13px;
  color: #5d3a00;
}
.test-banner .tb-left { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.test-banner .tb-icon { font-size: 16px; }
.test-banner .tb-title {
  font-weight: bold; padding: 2px 8px; background: #e67e22; color: #fff;
  border-radius: 3px; letter-spacing: 1px;
}
.test-banner .tb-info b { color: #c0392b; padding: 0 3px; }
.test-banner .tb-form,
.test-banner .tb-reset { display: flex; align-items: center; gap: 6px; margin: 0; }
.test-banner label { color: #5d3a00; }
.test-banner select {
  padding: 3px 6px; font-size: 13px; border: 1px solid #d59530;
  background: #fff; border-radius: 3px; cursor: pointer;
}
.test-banner .btn.sm { padding: 3px 10px; font-size: 12px; }
.test-banner .btn.sm:hover { background: #f39c12; color: #fff; }

/* ===== 保存结果浮层（2026-09-15）=====
   称重页表单很长、底部也有「保存」按钮，而 flash 在 <main> 顶部 —— 滚到底部保存时
   完全看不到提示。这个浮层固定在视口顶部，滚到哪都看得见。 */
.save-toast {
  position: fixed; z-index: 2000;
  left: 50%; top: 14px; transform: translateX(-50%);
  min-width: 300px; max-width: min(680px, calc(100vw - 28px));
  padding: 11px 38px 11px 14px;
  border-radius: 6px; font-size: 14px; line-height: 1.5;
  box-shadow: 0 8px 28px rgba(0,0,0,0.22);
  animation: saveToastIn .18s ease-out;
}
.save-toast.ok   { background: #e8f5e9; border: 1px solid #a5d6a7; color: #1b5e20; }
.save-toast.warn { background: #fff8e1; border: 1px solid #f0c36d; color: #8a6d00; }
.save-toast .st-line + .st-line { margin-top: 5px; }
.save-toast .st-x {
  position: absolute; right: 9px; top: 7px;
  width: 22px; height: 22px; line-height: 20px; text-align: center;
  border-radius: 4px; text-decoration: none; font-size: 13px;
  color: inherit; opacity: .6;
}
.save-toast .st-x:hover { opacity: 1; background: rgba(0,0,0,.07); }
@keyframes saveToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== 模态弹窗（2026-09-15：称重记录 —— 双击修改 / 调换互换） =====
   weighing.html 的 #editMask（双击记录改字段，重量只读）
   与 #swapMask（选另一条记录互换客户信息）共用这套样式。
   JS 通过切换 class 的 show 开合，因此这里只需 .modal-mask 与 .modal-mask.show。 */
.modal-mask {
  display: none;                       /* 默认收起 */
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(20, 30, 25, 0.42);
  padding: 32px 14px;
  overflow: auto;                      /* 小屏/字段多时可整体滚动 */
  -webkit-overflow-scrolling: touch;
}
.modal-mask.show { display: block; }
.modal-box {
  width: 100%; max-width: 880px; margin: 0 auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.22);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--primary-l);
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.modal-head b { color: var(--primary); }
.modal-x {
  margin-left: auto; flex: 0 0 auto;
  width: 26px; height: 26px; line-height: 24px; text-align: center;
  border-radius: 4px; text-decoration: none; color: var(--muted);
  font-size: 14px;
}
.modal-x:hover { background: #d9e6dc; color: var(--text); }
.modal-body { padding: 12px 14px 2px; }
/* 编辑窗字段：三列栅格，窄屏自动降为两列/一列 */
.modal-grid {
  display: grid; gap: 8px 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 12px 14px 2px;
}
.modal-grid .field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.modal-grid .field label { font-size: 12px; color: var(--muted); }
.modal-grid .field input,
.modal-grid .field select {
  width: 100%; box-sizing: border-box;
  padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 4px; background: #fff;
}
.modal-grid .field input[disabled] { background: #f3f5f4; color: var(--muted); }
.modal-grid .field input.ro { background: #eef1ef; color: var(--text); font-weight: 600; }
.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; margin-top: 10px;
  border-top: 1px solid var(--line); background: #fafbfa;
  font-size: 12px;
}
.modal-foot .btn { text-decoration: none; }
/* 调换窗：A 记录展示条 + 可点的其他记录列表 */
.swap-self {
  padding: 8px 10px; border-radius: 4px;
  background: var(--primary-l); border: 1px solid #cfe0d3;
  font-size: 13px;
}
.swap-list { display: flex; flex-direction: column; gap: 6px; padding-bottom: 12px; }
.swap-item {
  display: block; padding: 9px 11px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 4px;
  background: #fff; color: var(--text); text-decoration: none;
  transition: background .12s, border-color .12s;
}
.swap-item:hover { background: var(--primary-l); border-color: var(--primary); color: var(--primary-d); }
@media (max-width: 760px) {
  .modal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .modal-mask { padding: 14px 8px; }
  .modal-grid { grid-template-columns: 1fr; }
}

/* ---------- 表头点击排序（2026-10-02 现场需求） ---------- */
th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
th.th-sort:hover { background: rgba(0, 0, 0, 0.05); }
th.th-sort .sort-arrow { font-size: 0.8em; opacity: 0.65; }
