/* ============================================================
   敦煌印刷 · 绩效考核系统 v2.0
   UI 风格：清新简洁 · 浅蓝色调 · 响应式（PC 侧边栏 / 手机底部导航）
   ============================================================ */
:root {
  --blue-50: #f0f7ff;
  --blue-100: #e3f0fd;
  --blue-200: #c8e2fb;
  --blue-300: #9ccbf7;
  --blue-400: #64a9ef;
  --blue-500: #3b8fe0;
  --blue-600: #2f7cd6;
  --blue-700: #2565b3;
  --ink: #243342;
  --ink-2: #51637a;
  --ink-3: #8a9bad;
  --bg: #f2f7fc;
  --card: #ffffff;
  --line: #e3ecf5;
  --ok: #21a665;
  --ok-bg: #e5f7ee;
  --warn: #d9880f;
  --warn-bg: #fdf3e0;
  --bad: #d64545;
  --bad-bg: #fdecec;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(47, 124, 214, 0.08);
  --shadow-lg: 0 10px 34px rgba(47, 124, 214, 0.16);
  --tap: 44px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
input, select, textarea, button { font: inherit; color: inherit; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 16px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500) 55%, #5aa4ec);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar .logo { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; white-space: nowrap; }
.topbar .logo small { font-weight: 400; opacity: 0.85; margin-left: 6px; font-size: 12px; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 13px; opacity: 0.95; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .btn-ghost {
  height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.55); background: rgba(255,255,255,0.12);
  color: #fff; cursor: pointer; font-size: 13px;
}
.topbar .btn-ghost:active { background: rgba(255,255,255,0.25); }

/* ---------------- 页脚备案信息 ---------------- */
.site-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 16px;
  background: var(--card); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3); text-align: center;
}
.site-footer a { color: var(--blue); }
.site-footer a:hover { text-decoration: underline; }
.site-footer .sf-sep { color: var(--line); }
.site-footer .sf-copy { color: var(--ink-3); }

/* ---------------- 布局 ---------------- */
.layout { display: flex; min-height: calc(100vh - 94px); }
/* 侧边栏：固定在顶栏下方，独立滚动（内容再长导航也不跟着滚走） */
.sidebar {
  position: sticky; top: 56px; align-self: flex-start;
  width: 208px; flex-shrink: 0; padding: 12px 10px 24px;
  height: calc(100vh - 94px);
  background: var(--card); border-right: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--blue-200) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--blue-200); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--blue-300); }
.sidebar::-webkit-scrollbar-track { background: transparent; }
/* 所有可点行统一行高 40px、圆角 9px、外边距一致 */
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px; margin: 2px 0;
  border-radius: 9px; color: var(--ink-2); cursor: pointer;
  font-size: 14px; user-select: none; transition: background 0.15s, color 0.15s;
}
.sidebar .nav-item:hover { background: var(--blue-50); color: var(--blue-700); }
.sidebar .nav-item.active { background: var(--blue-100); color: var(--blue-700); font-weight: 600; }
.sidebar .nav-item .ico { width: 20px; text-align: center; font-size: 15px; opacity: 0.9; flex-shrink: 0; }
/* 一级分组标题：纯标签，不可点 */
.sidebar .nav-group { margin-top: 14px; }
.sidebar .nav-group:first-child { margin-top: 0; }
.sidebar .nav-group-title {
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px; margin: 0 0 2px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 1.5px;
  color: var(--ink-3); cursor: default; user-select: none;
}
.sidebar .nav-group-title .ico { font-size: 13px; opacity: 0.75; }
.sidebar .nav-group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
/* 二级项：缩进 + 左侧圆点，与一级行高一致 */
.sidebar .nav-item.sub {
  padding-left: 30px; position: relative; font-size: 13.5px;
}
.sidebar .nav-item.sub::before {
  content: ""; position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); opacity: 0.5;
  transition: background 0.15s, opacity 0.15s;
}
.sidebar .nav-item.sub:hover::before { background: var(--blue-500); opacity: 1; }
.sidebar .nav-item.sub.active { padding-left: 26px; border-left: 4px solid var(--blue-500); border-radius: 3px 9px 9px 3px; }
.sidebar .nav-item.sub.active::before { background: var(--blue-500); opacity: 1; left: 12px; }
.content { flex: 1; padding: 18px 22px 80px; max-width: 1200px; margin: 0 auto; min-width: 0; }


/* ---------------- 分段控件（加分/扣分 页签） ---------------- */
.seg { display: inline-flex; background: var(--blue-50); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn {
  border: none; background: transparent; cursor: pointer;
  height: 32px; padding: 0 16px; border-radius: 8px;
  font-size: 13.5px; color: var(--ink-2); transition: all 0.15s;
}
.seg-btn.active { background: var(--card); color: var(--blue-700); font-weight: 600; box-shadow: var(--shadow); }

/* ---------------- 卡片 / 标题 ---------------- */
.view-title { font-size: 19px; font-weight: 700; margin-bottom: 14px; color: var(--ink); }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px;
  border: 1px solid rgba(227, 236, 245, 0.7);
}
.card .toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px;
}
.card .toolbar b { font-size: 15px; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); font-size: 12.5px; }

/* ---------------- 表单控件（触控 ≥44px） ---------------- */
.fld { display: block; font-size: 12.5px; color: var(--ink-2); margin: 8px 0 4px; }
/* form-grid 内 label 固定单行高度，保证一行里各输入框顶部对齐 */
.form-grid label.fld { height: 18px; line-height: 18px; margin: 0 0 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 考核项 combobox 下拉 */
.combobox .cb-drop {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; padding: 4px;
}
.combobox .cb-group {
  padding: 8px 10px 3px; font-size: 11.5px; font-weight: 600; letter-spacing: 1px;
  color: var(--ink-3); position: sticky; top: 0; background: var(--card);
}
.combobox .cb-opt {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--ink);
}
.combobox .cb-opt:hover { background: var(--blue-50); }
.combobox .cb-opt b { color: var(--blue-700); flex-shrink: 0; }
.combobox .cb-opt .cb-meta { margin-left: auto; font-size: 12px; color: var(--ink-3); flex-shrink: 0; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fbfdff; outline: none; transition: border 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(100, 169, 239, 0.18);
  background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--blue-600); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row > div { min-width: 0; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  cursor: pointer; font-size: 14px; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--blue-300); color: var(--blue-700); }
.btn.primary {
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  border: none; color: #fff; font-weight: 600; box-shadow: 0 3px 10px rgba(59, 143, 224, 0.3);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--bad); border-color: #f3c8c8; background: #fff; }
.btn.danger:hover { background: var(--bad-bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
label.btn { cursor: pointer; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
.tbl th {
  text-align: left; padding: 10px 12px; white-space: nowrap;
  background: var(--blue-50); color: var(--blue-700); font-weight: 600;
  border-bottom: 1px solid var(--blue-100);
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover { background: #f8fbff; }
.tbl tr.sel { background: var(--blue-50); }
.tbl input { min-height: 36px; }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; line-height: 1.7; white-space: nowrap;
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.gray { background: #eef2f6; color: var(--ink-3); }
.tag.blue { background: var(--blue-100); color: var(--blue-700); }

/* ---------------- 统计卡 ---------------- */
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; text-align: center; border: 1px solid rgba(227,236,245,0.7);
}
.stat .n { font-size: 26px; font-weight: 700; color: var(--blue-600); }
.stat .l { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* ---------------- 看板分数徽章 ---------------- */
.score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; height: 34px; padding: 0 10px; border-radius: 10px;
  font-weight: 700; font-size: 15px;
}
.score-good { background: var(--ok-bg); color: var(--ok); }
.score-mid { background: var(--warn-bg); color: var(--warn); }
.score-low { background: var(--bad-bg); color: var(--bad); }
.score-top { background: var(--blue-100); color: var(--blue-700); }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: calc(100vh - 46px); display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #dcebfd 0%, #f2f7fc 45%, #e8f3ff 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 34px 30px;
}
.login-card h2 { color: var(--blue-700); font-size: 22px; letter-spacing: 1px; }
.login-card .sub { color: var(--ink-3); margin: 4px 0 18px; font-size: 13px; }
.login-card .btn { width: 100%; margin-top: 18px; min-height: 44px; }
.login-card .hint { margin-top: 14px; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(23, 43, 66, 0.4); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 680px; max-height: 88vh; overflow-y: auto;
  padding: 20px 22px;
}
.modal h3 { margin-bottom: 10px; color: var(--ink); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
/* 页签：切换 加减分记录 / 考勤考核记录 */
.tabs { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 2px solid var(--line); }
.tabbtn { border: none; background: none; padding: 10px 16px; font-size: 14.5px;
  color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabbtn.active { color: var(--blue); font-weight: 700; border-bottom-color: var(--blue); }

/* 手机端信息层级卡片（默认隐藏，桌面仍显示表格） */
.m-cards { display: none; }

/* 大弹框（绩效录入 / 考勤考核上传）：录入内容多、停留时间长，宽且可滚动 */
.modal-lg { max-width: 980px; width: min(980px, 96vw); padding: 22px 26px; }
.modal-mask.solid { background: rgba(23, 43, 66, 0.55); }
.att-rule { font-size: 12px; line-height: 1.6; max-width: 100%; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; top: 68px; left: 50%; transform: translateX(-50%);
  z-index: 200; background: #23364a; color: #fff; padding: 10px 22px;
  border-radius: 24px; font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease; max-width: 86vw;
}
.toast.err { background: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------------- 手机底部导航 ---------------- */
.bottomnav { display: none; }

/* ---------------- 打印 ---------------- */
.sign-doc { color: #000; }
.sign-doc h2 { text-align: center; font-size: 18px; margin-bottom: 4px; }
.sign-doc table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.sign-doc th, .sign-doc td { border: 1px solid #333; padding: 5px 8px; }
.sign-doc .meta { text-align: center; font-size: 12px; color: #333; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; padding: 12px; }
  .no-print { display: none !important; }
}

/* ============================================================
   移动端适配（≤768px）：底部导航 + 卡片化 + 无横向滚动
   ============================================================ */
@media (max-width: 768px) {
  .topbar { height: 52px; padding: 0 12px; }
  .topbar .user { display: none; }
  .layout { display: block; min-height: calc(100vh - 52px); }
  .sidebar { display: none; }
  .content { padding: 14px 12px calc(78px + env(safe-area-inset-bottom)); }
  .view-title { font-size: 17px; }
  .card { padding: 14px; border-radius: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .row > div { flex: 1 1 100%; }
  .row .btn, .row button { flex: 1 1 100%; }

  /* 大弹框手机端：全屏化、大点击区，方便手机录入 */
  .modal-lg { width: 100vw; max-width: 100vw; height: calc(100vh - 52px); max-height: none;
    border-radius: 16px 16px 0 0; padding: 16px 14px calc(20px + env(safe-area-inset-bottom)); }
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal .form-grid { grid-template-columns: 1fr; gap: 2px; }
  .modal input, .modal select { min-height: 44px; font-size: 16px; }
  .modal .btn { min-height: 44px; }
  .cb-drop { max-height: 46vh; }

  /* 绩效记录页：用专门设计的 m-cards 卡片，隐藏对应表格 */
  .m-cards { display: block; }
  .table-wrap.hide-m { display: none; }
  .mcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
  .mc-top { display: flex; align-items: center; gap: 10px; }
  .mc-ava { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; color: #fff; font-weight: 700; font-size: 15px; flex-shrink: 0;
    background: var(--blue); }
  .mc-ava.ok { background: #16a34a; }
  .mc-ava.bad { background: #dc2626; }
  .mc-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .mc-who b { font-size: 15.5px; }
  .mc-sub { font-size: 12px; color: var(--ink-3); word-break: break-all; }
  .mc-score { font-size: 21px; font-weight: 800; flex-shrink: 0; font-variant-numeric: tabular-nums; }
  .mc-score.pos { color: #16a34a; }
  .mc-score.neg { color: #dc2626; }
  .mc-main { margin-top: 9px; font-size: 13.5px; font-weight: 600; word-break: break-all; }
  .mc-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center;
    font-size: 12.5px; color: var(--ink-2); }
  .mini { font-size: 11px; padding: 2px 8px; border-radius: 9px; flex-shrink: 0; }
  .mini.ok { background: #e5f5ea; color: #15803d; }
  .mini.warn { background: #fdf1dd; color: #b45309; }
  .mini.gray { background: var(--line); color: var(--ink-3); }
  .mini.bad { background: #fde5e5; color: #dc2626; }
  .chip { background: #f3f5f8; border-radius: 9px; padding: 5px 11px; font-size: 12.5px;
    color: var(--ink-2); white-space: nowrap; }
  .mc-score.zero { color: var(--ink-3); font-weight: 600; font-size: 18px; }
  .chip.warn { background: #fdf1dd; color: #b45309; }
  .mc-remark { margin-top: 9px; font-size: 12.5px; color: var(--ink-2); background: #f7f9fb;
    border-radius: 9px; padding: 7px 11px; word-break: break-all; }
  .mc-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
  .mempty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 34px 12px; }

  /* 其他页面列表卡片化：每条记录一张卡，一卡看完所有字段（td 由脚本自动标注列名） */
  .table-wrap { overflow-x: hidden; }
  table.tbl { min-width: 0 !important; width: 100% !important; }
  .tbl td, .tbl td .tag { white-space: normal; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; width: 100%; }
  .tbl tr { display: block; background: var(--card); border: 1px solid var(--line);
    border-radius: 12px; margin: 0 0 10px; padding: 6px 12px; box-shadow: var(--shadow); }
  .tbl td { display: flex; justify-content: space-between; align-items: center; gap: 14px;
    border: none; padding: 7px 0; text-align: right; font-size: 13.5px; word-break: break-all; }
  .tbl td::before { content: attr(data-l); color: var(--ink-3); font-size: 12.5px;
    text-align: left; flex-shrink: 0; max-width: 40%; }
  .tbl td[data-l=""]::before { display: none; }
  .tbl td:empty { display: none; }

  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: var(--tap); font-size: 11px; color: var(--ink-3); cursor: pointer; gap: 1px;
  }
  .bottomnav .bn-item .ico { font-size: 19px; line-height: 1.2; }
  .bottomnav .bn-item.active { color: var(--blue-600); font-weight: 600; }

  /* 更多菜单（抽屉） */
  .sheet-mask { position: fixed; inset: 0; z-index: 90; background: rgba(23,43,66,0.35); }
  .sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 91;
    background: #fff; border-radius: 18px 18px 0 0; padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg); animation: sheet-up 0.22s ease;
  }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
  .sheet .sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .sheet .sheet-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 12px 4px; border-radius: 12px; cursor: pointer; font-size: 12px; color: var(--ink-2);
  }
  .sheet .sheet-item:active { background: var(--blue-50); }
  .sheet .sheet-item.active { background: var(--blue-100); color: var(--blue-700); font-weight: 600; }
  .sheet .sheet-item .ico { font-size: 22px; }

  /* 表格在手机端保持横向轻滚动但不撑破页面 */
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  table.tbl { min-width: 520px; }

  .modal { max-height: 92vh; border-radius: 16px 16px 0 0; align-self: flex-end; }
  .modal-mask { align-items: flex-end; }
}
