/* 佳德美 v2 PC 客户端（测试版）· 样式
   视觉规格对齐 WinForms 原生观感：微软雅黑 9pt、灰底窗体、TabControl、DataGridView 交替行 */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 13px; color: #1f2937; background: #eef1f5;
  -webkit-user-select: none; user-select: none;
}
button, input, select, textarea { font-family: inherit; font-size: 13px; }
.hide { display: none !important; }

/* ---------------- 通用控件 ---------------- */
.btn {
  height: 26px; padding: 0 12px; margin-right: 5px;
  background: #e8ebf0; border: 1px solid #b9c0cb; border-radius: 2px;
  color: #1f2937; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #dbe4f2; border-color: #7d97c4; }
.btn:active { background: #cbd8ee; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.blue   { background: #e6f0ff; border-color: #9dbdea; }
.btn.blue:hover { background: #d3e4ff; }
.btn.blue2  { background: #f0f5ff; border-color: #adc4ea; }
.btn.blue2:hover { background: #e0eaff; }
.btn.green  { background: #e6ffe6; border-color: #9ccf9c; }
.btn.green:hover { background: #d2f7d2; }
.btn.red    { background: #ffebeb; border-color: #e0a0a0; }
.btn.red:hover { background: #ffdcdc; }
.btn.red2   { background: #ffdcdc; border-color: #d98c8c; }
.btn.red2:hover { background: #ffc9c9; }
.btn.amber  { background: #fff4e0; border-color: #e0b878; }
.btn.amber:hover { background: #ffeccc; }
.btn.primary{ background: #1e5aa8; border-color: #17498a; color: #fff; font-weight: 700; }
.btn.primary:hover { background: #2b6cb0; }

.inp {
  height: 26px; padding: 0 7px; background: #fff;
  border: 1px solid #b9c0cb; border-radius: 2px; color: #1f2937; outline: none;
  -webkit-user-select: text; user-select: text;
}
.inp:focus { border-color: #2b6cb0; box-shadow: 0 0 0 2px rgba(43,108,176,.15); }
select.inp { padding-right: 2px; }
textarea.inp { height: auto; padding: 5px 7px; resize: vertical; line-height: 1.6; }

/* ---------------- 登录页 ---------------- */
#loginScreen {
  height: 100%; display: flex; align-items: center; justify-content: center;
  /* 瓷砖展厅背景图 + 深蓝压暗层（保证白卡与文字可读），图片加载失败回退渐变 */
  background: linear-gradient(120deg, rgba(14,40,78,.62) 0%, rgba(20,52,98,.42) 50%, rgba(14,40,78,.62) 100%),
    url('login-bg.jpg') center/cover no-repeat,
    linear-gradient(135deg, #1e5aa8 0%, #2b6cb0 45%, #3d8bd4 100%);
}
.loginCard {
  width: 380px; background: #fff; border-radius: 6px; padding: 30px 34px 26px;
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
}
.loginCard h1 { margin: 0 0 4px; font-size: 19px; color: #17498a; letter-spacing: .5px; }
.loginCard .sub { font-size: 12px; color: #7b8794; margin-bottom: 22px; }
.loginCard label { display: block; margin: 12px 0 5px; color: #4b5563; font-size: 12px; }
.loginCard .inp { width: 100%; height: 34px; }
.loginCard button { width: 100%; height: 36px; margin-top: 20px; font-size: 14px; }
#loginMsg { margin-top: 12px; font-size: 12px; color: #c0392b; min-height: 16px; }
.loginHint { margin-top: 16px; padding-top: 12px; border-top: 1px dashed #dbe1ea; color: #8892a0; font-size: 11px; line-height: 1.8; }

/* ---------------- 主界面 ---------------- */
#mainScreen { height: 100%; display: flex; flex-direction: column; }
#banner {
  height: 46px; flex: 0 0 46px; display: flex; align-items: center;
  padding: 0 14px; background: linear-gradient(180deg, #2b6cb0 0%, #1e5aa8 100%);
  color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.22);
}
#banner .brand { font-size: 15px; font-weight: 700; letter-spacing: .6px; }
#banner .ver {
  font-size: 11px; font-weight: 400; margin-left: 6px; padding: 1px 6px;
  background: rgba(255,255,255,.22); border-radius: 9px;
}
#banner .sp { flex: 1; }
#banner .who { font-size: 12px; margin-right: 12px; opacity: .95; }
#banner .btn {
  background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.4); color: #fff;
}
#banner .btn:hover { background: rgba(255,255,255,.28); }

/* 标签栏 */
#tabbar {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; background: #dde3ec;
  border-bottom: 1px solid #a9b3c2; padding: 3px 6px 0; gap: 2px;
}
.tab {
  padding: 6px 15px; background: #cfd7e3; border: 1px solid #a9b3c2; border-bottom: none;
  border-radius: 3px 3px 0 0; cursor: pointer; color: #33415c; font-size: 12px;
  position: relative; top: 1px;
}
.tab:hover { background: #e4eaf3; }
.tab.on { background: #fff; color: #17498a; font-weight: 700; border-color: #7d97c4; }
#view { flex: 1; overflow: hidden; background: #fff; display: flex; flex-direction: column; }

/* 页内工具条 */
.bar {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  padding: 7px 9px; background: #eff3f9; border-bottom: 1px solid #d3dae5;
}
.bar .lbl { color: #4b5563; }
.bar .sep { width: 1px; height: 20px; background: #c3cbd8; margin: 0 3px; }
.bar .tip { color: #7b8794; font-size: 11px; margin-left: auto; }

/* 提示横幅 */
.alert {
  flex: 0 0 auto; display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; background: #fef3c7; border-bottom: 1px solid #fcd34d;
  color: #92400e; font-size: 12px;
}
.alert .x {
  margin-left: auto; background: #fff; border: 1px solid #e0a94a; color: #b45309;
  border-radius: 2px; height: 24px; padding: 0 12px; cursor: pointer; white-space: nowrap;
}
.alert .x:hover { background: #fff8e6; }
.alert.info { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }
.alert.info .x { border-color: #7dd3fc; color: #0369a1; }

/* 统计卡片 */
.kpis { flex: 0 0 auto; display: flex; gap: 10px; padding: 10px 9px 4px; flex-wrap: wrap; background: #fff; }
.kpi {
  flex: 1 1 0; min-width: 118px; border: 1px solid #dbe2ec; border-left: 3px solid #2b6cb0;
  border-radius: 3px; padding: 7px 11px; background: #f9fbfe;
}
.kpi .k { color: #7b8794; font-size: 11px; }
.kpi .v { font-size: 19px; font-weight: 700; color: #17498a; line-height: 1.35; }
.kpi.g { border-left-color: #16a34a; } .kpi.g .v { color: #15803d; }
.kpi.o { border-left-color: #d97706; } .kpi.o .v { color: #b45309; }
.kpi.r { border-left-color: #dc2626; } .kpi.r .v { color: #b91c1c; }
.kpi.p { border-left-color: #7c3aed; } .kpi.p .v { color: #6d28d9; }

/* 表格 */
.tblWrap { flex: 1; overflow: auto; border-top: 1px solid #e3e8f0; }
table.tbl { border-collapse: separate; border-spacing: 0; width: 100%; }
table.tbl th {
  position: sticky; top: 0; z-index: 2;
  background: linear-gradient(180deg, #f2f5fa 0%, #dfe6f0 100%);
  border-right: 1px solid #cdd6e3; border-bottom: 1px solid #b9c4d4;
  padding: 7px 10px; text-align: left; font-weight: 700; color: #33415c; white-space: nowrap;
}
table.tbl td {
  border-right: 1px solid #edf1f7; border-bottom: 1px solid #edf1f7;
  padding: 6px 10px; white-space: nowrap;
}
table.tbl tfoot td {
  border-top: 2px solid #cdd6e3; padding: 7px 10px; white-space: nowrap;
}
table.tbl tbody tr:nth-child(even) { background: #f8fafd; }
table.tbl tbody tr:hover { background: #eaf2ff; }
table.tbl tbody tr.sel { background: #d8e8ff !important; }
table.tbl tbody tr.warnRow { background: #fff1f0 !important; }
table.tbl td.num, table.tbl th.num { text-align: right; }
.tbl .empty { text-align: center; color: #98a2b3; padding: 30px; }

.v-in  { color: #15803d; font-weight: 700; }   /* 入库 绿 */
.v-out { color: #dc2626; font-weight: 700; }   /* 出库 红 */
.v-dmg { color: #dc2626; font-weight: 700; }   /* 破损 红 */
.v-smp { color: #b45309; font-weight: 700; }   /* 样品 琥珀 */
.v-zero{ color: #b91c1c; font-weight: 700; }
.v-pend{ color: #c27403; font-weight: 700; }   /* 下单/待处理订单 琥珀加 */

/* 列表内「日志」「下单」小入口 */
td .pLog {
  display: inline-block; margin-left: 5px; padding: 0 5px; border-radius: 3px;
  font-size: 11px; font-weight: 400; color: #1e5aa8; background: #e8f0fb;
  border: 1px solid #c8daf0; cursor: pointer; line-height: 16px; vertical-align: 1px;
}
td .pLog:hover { background: #1e5aa8; color: #fff; }
td.pOrder { cursor: pointer; }
td.pOrder:hover { background: #fdf3e3; }
td.pOrder.v-pend { cursor: pointer; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 9px; font-size: 11px; border: 1px solid; }
.b-unconfirmed { color: #6d28d9; border-color: #c4b5fd; background: #f5f3ff; }
.b-pending     { color: #b45309; border-color: #fcd34d; background: #fffbeb; }
.b-processing  { color: #1d4ed8; border-color: #93c5fd; background: #eff6ff; }
.b-audited     { color: #b45309; border-color: #fbbf24; background: #fff7ed; font-weight: 700; }
.b-completed   { color: #15803d; border-color: #86efac; background: #f0fdf4; }
.b-cancelled   { color: #64748b; border-color: #cbd5e1; background: #f8fafc; }
.b-issued      { color: #0369a1; border-color: #7dd3fc; background: #f0f9ff; }
.tag { display: inline-block; padding: 0 6px; border-radius: 3px; background: #eef2f7; color: #475569; font-size: 11px; }

/* chip（同商品待处理） */
.chips { flex: 0 0 auto; padding: 7px 9px; background: #f7f9fc; border-top: 1px solid #e3e8f0; }
.chips .ct { color: #4b5563; margin-bottom: 5px; }
.chips .ct b { color: #17498a; }
.chip {
  display: inline-block; margin: 0 5px 4px 0; padding: 3px 9px; background: #fff;
  border: 1px solid #c8d3e3; border-radius: 11px; cursor: pointer; font-size: 11px;
}
.chip:hover { background: #eaf2ff; border-color: #7d97c4; }

/* 分页 */
.pager { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-top: 1px solid #e3e8f0; background: #fbfcfe; }
.pager .n { color: #64748b; }

/* 弹窗 */
#modalWrap {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 160; /* [c202] 100→160：必须高于 loadMask(150)，否则「查数据→弹确认框」时遮罩盖住弹窗按钮=页面假死 */
}
.modal {
  background: #fff; border-radius: 5px; min-width: 420px; max-width: 900px;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.32);
}
.modal h3 { margin: 0; padding: 12px 16px; background: #eff3f9; border-bottom: 1px solid #d3dae5; font-size: 13px; color: #17498a; border-radius: 5px 5px 0 0; }
.modal .body { padding: 14px 16px; overflow: auto; }
.modal .foot { padding: 10px 16px; border-top: 1px solid #e3e8f0; text-align: right; background: #fbfcfe; border-radius: 0 0 5px 5px; }
.frow { display: flex; align-items: center; margin-bottom: 9px; }
.frow label { width: 96px; color: #4b5563; flex: 0 0 96px; text-align: right; padding-right: 10px; }
.frow .inp { flex: 1; }
.frow .hint { color: #98a2b3; font-size: 11px; margin-left: 8px; }
/* 双列表单（相邻 half 字段并排，参考旧系统新增商品弹窗） */
.fgrid { display: flex; flex-wrap: wrap; }
.fgrid .frow { width: 100%; }
.fgrid .frow.half { width: 50%; box-sizing: border-box; padding-right: 10px; }
.fgrid .frow.half + .frow.half { padding-right: 0; padding-left: 10px; }

/* Toast */
#toastWrap { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  min-width: 190px; max-width: 460px; padding: 9px 14px; border-radius: 4px;
  background: #1f2937; color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.28);
  animation: tin .18s ease-out; line-height: 1.6; font-size: 12px;
  -webkit-user-select: text; user-select: text;
}
.toast.ok  { background: #15803d; }
.toast.err { background: #b91c1c; }
.toast.warn{ background: #b45309; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 加载遮罩 */
#loadMask {
  position: fixed; inset: 0; background: rgba(255,255,255,.62); z-index: 150;
  display: flex; align-items: center; justify-content: center; color: #17498a; font-size: 13px;
}
#loadMask .box { background: #fff; border: 1px solid #c8d3e3; border-radius: 4px; padding: 14px 26px; box-shadow: 0 8px 24px rgba(0,0,0,.16); }

/* 子标签（基础数据） */
.subtabs { flex: 0 0 auto; display: flex; gap: 3px; padding: 7px 9px 0; background: #f7f9fc; border-bottom: 1px solid #d3dae5; }
.subtab { padding: 5px 14px; background: #e6ebf3; border: 1px solid #c3cbd8; border-bottom: none; border-radius: 3px 3px 0 0; cursor: pointer; color: #33415c; }
.subtab:hover { background: #eff4fb; }
.subtab.on { background: #fff; color: #17498a; font-weight: 700; border-color: #7d97c4; }

.scroll { flex: 1; overflow: auto; padding: 12px; }
.note { color: #64748b; font-size: 11px; line-height: 1.9; }
.note b { color: #33415c; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.card { border: 1px solid #dbe2ec; border-radius: 4px; padding: 10px 12px; background: #fbfcfe; }
.card h4 { margin: 0 0 8px; font-size: 12px; color: #17498a; }
.card .kv { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #e8edf5; }
.card .kv:last-child { border-bottom: none; }
/* [c241] 左侧标签不参与压缩，避免「业务数据」被挤成两行 */
.card .kv span:first-child { color: #64748b; flex: 0 0 auto; white-space: nowrap; margin-right: 12px; }
.card .kv span:last-child { font-weight: 700; color: #1f2937; text-align: right; word-break: break-word; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 9px; font-size: 11px; }
.pill.ok { background: #dcfce7; color: #15803d; }
.pill.bad { background: #fee2e2; color: #b91c1c; }
.pill.off { background: #f1f5f9; color: #64748b; }

/* ==== 行级快捷出入库（本日入库/本日出库/破损/样品 单元格） ==== */
td.pAct { position: relative; cursor: pointer; }
td.pAct:hover { background: #eef4fb; }
td.pAct .pAdd {
  display: none;
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; line-height: 14px; text-align: center;
  border-radius: 4px; background: #1e5aa8; color: #fff; font-size: 12px; font-weight: 700;
}
td.pAct:hover .pAdd { display: inline-block; }
td.pAct:hover .pActVal { opacity: 0.45; }

/* ==== 分页条 ==== */
.pager {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #f7f9fc; border-top: 1px solid #e3e8f0;
  position: sticky; bottom: 0; z-index: 2;
}
.pager .pgInfo { color: #4b5563; font-size: 12.5px; white-space: nowrap; }
.pager .pgInfo b { color: #17498a; }
.pager .btn[disabled] { opacity: .45; cursor: default; }
.pager select.inp { width: auto; }

/* ==================== [c251] 移动端适配 ====================
   生效条件：视口宽度 ≤820px（手机竖屏/横屏、小平板）。
   ★ ≥821px 完全不受影响——桌面端布局与改动前逐像素一致，本段所有规则都不参与计算。
   配合 pc.html 新增的 <meta name="viewport" content="width=device-width">：
   此前没有 viewport，手机按 980px 虚拟视口渲染后整体缩小约 0.40 倍，
   13px 正文实际只有 5.2px、按钮高度约 10px，几乎无法点按。
   本段只调「容器宽度/换行/滚动方式/触控目标尺寸」，不改任何业务元素的结构与顺序。 */
@media (max-width: 820px) {
  /* 地址栏收起/展开时用动态视口高度，避免底部被顶出屏幕；不支持 dvh 的旧内核自动沿用上面的 100% */
  html, body { height: 100dvh; }

  /* 登录卡：不再固定 380px，避免左右贴边 */
  .loginCard { width: min(92vw, 380px); padding: 24px 20px 20px; border-radius: 8px; }
  .loginCard h1 { font-size: 17px; }
  .loginCard .sub { margin-bottom: 16px; }

  /* 顶栏：允许换行（原来 46px 单行放不下品牌+用户名+两个按钮），触控目标放大到 30px */
  #banner { height: auto; flex: 0 0 auto; flex-wrap: wrap; padding: 6px 10px; row-gap: 6px; }
  #banner .brand { font-size: 13px; letter-spacing: 0; }
  #banner .ver { font-size: 10px; margin-left: 4px; }
  #banner .who { font-size: 11px; margin-right: 8px; }
  #banner .btn { height: 30px; padding: 0 10px; font-size: 12px; margin-right: 4px; }

  /* 页签：由「换行堆叠」改为「单行横向滑动」，否则 10 个页签会吃掉半屏高度 */
  #tabbar {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 3px 4px 0;
  }
  #tabbar::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 9px 13px; font-size: 12.5px; }

  /* 页内工具条 / 统计卡 */
  .bar { padding: 6px 8px; gap: 5px; }
  .bar .tip { display: none; }            /* 说明文字在窄屏只会挤占按钮，信息价值低于可操作性 */
  .kpis { gap: 6px; padding: 8px 8px 4px; }
  .kpi { min-width: calc(50% - 3px); padding: 6px 9px; }
  .kpi .v { font-size: 17px; }

  /* 表格：容器横向滚动 + 惯性滑动；单元格收紧，尽量一屏多看到几列（列顺序、内容不变） */
  .tblWrap { -webkit-overflow-scrolling: touch; }
  table.tbl th, table.tbl td { padding: 6px 8px; }
  table.tbl th { font-size: 12.5px; }

  /* 分页条：允许换行，不再把按钮挤出可视区 */
  .pager { flex-wrap: wrap; gap: 6px; padding: 7px 8px; }
  .pager .pgInfo { font-size: 12px; }

  /* 弹窗：JS 会给 .modal 写内联 min-width（最长见过 600px），窄屏必须 !important 才压得住 */
  .modal {
    min-width: 0 !important; width: 94vw !important; max-width: 94vw !important;
    max-height: 86vh; border-radius: 8px;
  }
  .modal .body { padding: 12px; }
  .modal .foot { padding: 10px 12px; }
  .frow label { width: 78px; flex: 0 0 78px; padding-right: 8px; }
  .fgrid .frow.half { width: 100%; padding-right: 0; padding-left: 0; }

  /* 输入类控件用 16px：iOS Safari 对 <16px 的输入框聚焦时会自动放大页面（移动端最常见的手感问题） */
  .inp, .loginCard .inp { font-size: 16px; height: 32px; }
  textarea.inp { height: auto; }

  /* Toast 贴满宽度：原来 max-width:460px 在 390px 屏上会溢出 */
  #toastWrap { left: 8px; right: 8px; bottom: 8px; align-items: stretch; }
  .toast { min-width: 0; max-width: none; font-size: 13px; }

  /* 小字块略放大，保证窄屏可读 */
  .note, .loginHint { font-size: 12px; }
}

