* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6f9;
  --side: #1f2a44;
  --side-hi: #2c3a5e;
  --card: #ffffff;
  --line: #e3e8ef;
  --txt: #1f2a44;
  --muted: #7a869a;
  --primary: #2f6df0;
  --green: #1aa86b;
  --red: #e0524d;
  --amber: #e6a23c;
}
body { font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--txt); }
#app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 210px; background: var(--side); color: #cfd8e6; display: flex; flex-direction: column; }
.brand { padding: 16px; border-bottom: 1px solid #2c3a5e; display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 40px; height: 40px; border-radius: 9px; flex: 0 0 auto; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-co { font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: #9fb0c9; }
#nav { flex: 1; padding: 8px; overflow-y: auto; }
#nav button { display: block; width: 100%; text-align: left; background: none; border: 0; color: #cfd8e6;
  padding: 11px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; margin-bottom: 4px; }
#nav button:hover { background: var(--side-hi); }
#nav button.active { background: var(--primary); color: #fff; }
.side-foot { padding: 12px 16px; font-size: 12px; color: #6b7790; border-top: 1px solid #2c3a5e; }

/* Main */
main { flex: 1; display: flex; flex-direction: column; }
#topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px;
  background: #fff; border-bottom: 1px solid var(--line); }
.tb-left { display: flex; align-items: center; gap: 10px; }
.tb-logo { width: 30px; height: 30px; border-radius: 7px; }
#page-title { font-size: 18px; font-weight: 700; }
#clock { color: var(--muted); font-size: 13px; }
#view { padding: 24px; overflow-y: auto; }

/* Cards (dashboard) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.stat .num { font-size: 30px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.green .num { color: var(--green); }
.stat.blue .num { color: var(--primary); }
.stat.red .num { color: var(--red); }
.stat.amber .num { color: var(--amber); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.mini-stat { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 20px; }
.panel h3 { font-size: 15px; margin-bottom: 12px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:hover td { background: #f8fafc; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.tag.run { background: #e3f6ee; color: var(--green); }
.tag.stop { background: #fdeaea; color: var(--red); }
.tag.warn { background: #fdf3e3; color: var(--amber); }
.tag.blue { background: #e7f0fe; color: var(--primary); }

/* Buttons / toolbar */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
/* 设备台账责任人筛选：标签不换行，下拉宽度适中（避免挤压成竖排字） */
.toolbar label { white-space: nowrap; }
.toolbar select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-family: inherit; font-size: 13px; min-width: 120px; max-width: 200px; }
/* 工具栏内的输入框：整体 flex 布局下不能让 width:100% 撑满一行 */
.toolbar input { width: auto; flex: 1 1 200px; min-width: 140px; padding: 6px 10px; font-size: 13px; }
.toolbar input[readonly] { background: #f6f8fb; }

/* 页内页签（如 产品与物料 的下级主数据页签） */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.tab { background: #eef2f8; color: var(--txt); border: 1px solid transparent; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-family: inherit; }
.tab:hover { background: #e4ebf5; }
.tab.active { background: var(--primary); color: #fff; }

/* 物料入库：料号模糊检索结果列表 */
.mat-list { border: 1px solid var(--line); border-radius: 8px; max-height: 210px; overflow: auto; background: var(--panel, #fff); }
.mat-list:empty { display: none; }
.mat-row { padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.mat-row:last-child { border-bottom: 0; }
.mat-row:hover { background: #f2f6fb; }
.mat-row.on { background: #e2ecfa; box-shadow: inset 3px 0 0 var(--primary); }

/* 设备/产线：设备选择器 + 文档下载按钮 + 保养到期提示 */
.equip-sel { align-items: center; flex-wrap: wrap; }
.toolbar .hint { flex: 1 1 260px; }
table a.btn { display: inline-block; line-height: 1.35; }
table a.btn:hover { opacity: .92; }
#eq-doc-file, #eq-file { padding: 6px 8px; background: #f8fafc; }
.modal .hint { margin-bottom: 4px; }

/* DCC 文控中心：文件列表检索框 + 状态/收回标签 + 弹窗内表格 */
#dcc-kw, #dcc-file, #dcc-rev-file { padding: 7px 10px; background: #f8fafc; }
#dcc-kw { flex: 0 1 260px; }
.toolbar .hint b { color: var(--primary); }
.panel h3 { display: flex; align-items: center; gap: 8px; }
table .hint { background: none; border: 0; padding: 0; margin: 0 0 0 4px; font-size: 11px; }
.modal table.log a { color: var(--primary); }
.modal table.log td { word-break: break-all; }

button.btn { background: var(--primary); color: #fff; border: 0; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; }
button.btn:hover { opacity: .92; }
button.btn.ghost { background: #eef2f8; color: var(--txt); }
button.btn.sm { padding: 5px 10px; font-size: 12px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* Modal（top/left/right/bottom 写法兼容旧版 Chrome 70，不支持 inset 简写） */
#modal-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,.45); display: flex;
  align-items: center; justify-content: center; z-index: 50; }
#modal-mask.hidden { display: none; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 92vw; padding: 22px;
  max-height: 88vh; overflow-y: auto; }
/* 报工弹窗字段较多：加宽版 */
.modal.wide { width: 880px; }
@media (max-width: 960px) { .modal.wide { width: 94vw; } }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .row3 { grid-template-columns: 1fr; } }
/* 报工：分组小标题 */
.form-sec { margin: 14px 0 6px; padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: 13px; font-weight: 600; color: var(--txt); }
.form-sec:first-child { margin-top: 4px; padding-top: 0; border-top: 0; }
/* 报工：不良原因明细表 */
.defect-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.defect-tbl th, .defect-tbl td { border: 1px solid #eef0f4; padding: 6px 8px; text-align: left; vertical-align: middle; }
.defect-tbl th { background: #f7f9fc; font-weight: 600; color: var(--muted); font-size: 12px; }
.defect-tbl td input[type="number"] { width: 90px; }
.defect-tbl td input[type="text"] { width: 100%; }
/* 检验包装两级不良表行数较多：限高滚动，避免弹窗过长 */
#defect-holder .defect-tbl { display: block; max-height: 320px; overflow-y: auto; }
#defect-holder .defect-tbl thead, #defect-holder .defect-tbl tbody { display: table; width: 100%; table-layout: fixed; }
/* 报工：异常原因多选 */
.abn-chks { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 6px 0; }
.abn-sum { font-size: 12px; color: var(--muted); padding-top: 4px; }
/* 报工：人员明细（每岗可多人，每人独立工时） */
.staff-tbl select { width: 100%; }
.staff-tbl td input[type="number"] { width: 110px; }
.staff-bar { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.staff-bar .abn-sum { padding-top: 0; }
.modal h3 { margin-bottom: 8px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal table.log { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
.modal table.log th, .modal table.log td { border: 1px solid #eef0f4; padding: 7px 9px; text-align: left; vertical-align: top; }
.modal table.log th { background: #f6f8fb; color: #44506a; font-weight: 600; white-space: nowrap; }
.modal table.log b { color: #1f6feb; }

/* Login */
#login-screen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(135deg,#1f2a44,#2c3a5e);
  display: flex; align-items: center; justify-content: center; z-index: 100; }
.login-box { background: #fff; border-radius: 14px; padding: 30px; width: 340px; max-width: 92vw; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-brand { text-align: center; margin-bottom: 18px; color: var(--side); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.login-logo { width: 64px; height: 64px; border-radius: 14px; margin-bottom: 6px; box-shadow: 0 6px 16px rgba(30,64,175,.25); }
.login-co { font-size: 20px; font-weight: 700; }
.login-sub { font-size: 13px; color: #8a96ad; }
.login-err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 6px; text-align: center; }
.login-tip { margin-top: 14px; color: var(--muted); font-size: 12px; text-align: center; }
/* 登录：密码框小眼睛（显示/隐藏密码） */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center; background: none; border: none; padding: 0;
  cursor: pointer; color: #8a96ad; border-radius: 6px; }
.pw-eye:hover { color: var(--txt); background: #eef2f8; }
#user-info { display: flex; align-items: center; gap: 10px; }
.ui-name { font-size: 13px; color: var(--txt); }
.muted { color: var(--muted); font-size: 12px; }

/* 培训考核 / 上岗证 */
.chks { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 6px 0; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--txt); margin: 0; cursor: pointer; }
.chk input { width: auto; }
/* 权限设置：按模块分组的勾选块 */
.perm-group { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; background: #fbfcfe; }
.perm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13px; font-weight: 600; color: var(--txt); padding-bottom: 4px; border-bottom: 1px dashed var(--line); }
.perm-all { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 400;
  color: var(--muted); margin: 0; cursor: pointer; }
.perm-all input { width: auto; }
.perm-group .chks { padding: 8px 0 2px; }
.perm-group .chk { font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); background: #f3f6fb; border: 1px dashed var(--line);
  padding: 8px 10px; border-radius: 8px; margin-top: 6px; }
.badge-card { border-radius: 12px; overflow: hidden; }
.bc-hd { background: linear-gradient(135deg, #1e6fd9, #13b3a6); color: #fff; padding: 14px 18px; }
.bc-hd h3 { margin: 0; font-size: 18px; }
.bc-hd div { font-size: 11px; opacity: .85; letter-spacing: 1px; margin-top: 2px; }
.bc-co { display: flex; align-items: center; font-size: 12px; opacity: .95; margin-bottom: 8px; }
.bc-co img { width: 22px; height: 22px; border-radius: 5px; margin-right: 8px; background: #fff; padding: 2px; }
.bc-body { padding: 8px 18px 16px; }
.bc-body .row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.bc-body .row span:first-child { color: var(--muted); }
.bc-body .row b { font-weight: 600; }
.bc-body .skills { margin-top: 8px; }
.bc-body .skills h4 { margin: 6px 0; font-size: 13px; color: var(--primary); }
.bc-body .skills ul { margin: 0; padding-left: 18px; font-size: 13px; color: #444; }
.bc-body .qr { text-align: center; margin-top: 12px; }
.bc-body .qr svg { width: 168px; height: 168px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.bc-body .tip { font-size: 12px; color: var(--muted); margin-top: 4px; }
.bc-actions { text-align: center; margin-top: 10px; }

/* ============ 移动端响应式 ============ */
.menu-btn { display: none; align-items: center; justify-content: center; width: 38px; height: 38px;
  border: 0; background: #eef2f8; color: var(--side); border-radius: 8px; font-size: 20px; cursor: pointer; margin-right: 8px; }
#drawer-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,.45); z-index: 55; display: none; }

@media (max-width: 820px) {
  .menu-btn { display: inline-flex; }
  #app { flex-direction: column; }
  /* 侧栏变为抽屉：默认移出屏幕，点击菜单滑入，带遮罩 */
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 240px; max-width: 80vw;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 60; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,.35); }
  #drawer-mask.show { display: block; }
  /* 顶栏/内容间距收紧 */
  #topbar { padding: 10px 14px; }
  #page-title { font-size: 16px; }
  #view { padding: 14px; }
  /* 表格横向滚动，避免小屏挤成一团 */
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { width: auto !important; min-width: 560px; }
  /* 仪表盘卡片两列自适应 */
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  /* 监控中心两栏在手机上堆叠为单列 */
  .grid2 { grid-template-columns: 1fr; }
  /* 弹窗全屏可滚动 */
  .modal { width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; overflow-y: auto; }
  /* 导航按钮加大，便于手指点按 */
  #nav button { font-size: 15px; padding: 13px 14px; }
  /* 表单两列改单列，避免挤压 */
  .row2 { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  #clock { display: none; }
}

/* 假勤管理：视图切换条（台账 / 我的休假申请 / 休假审批） */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 14px; }
.subtab { background: #f1f5f9; color: var(--txt); border: 1px solid var(--line); padding: 6px 13px;
  border-radius: 999px; cursor: pointer; font-size: 12.5px; font-family: inherit; }
.subtab:hover { background: #e6edf6; }
.subtab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
/* 休假申请：天数字段实时提示 + 审批弹窗内的信息行更紧凑 */
#modal-mask #lv-tip { background: #f8fafc; border: 1px dashed var(--line); border-radius: 6px; padding: 6px 9px; }
.modal table, .panel table { table-layout: auto; }
