/* ===========================================================
 *  移动端适配 + 手机专属组件
 *  断点：900px（平板竖屏 / 大屏手机）、560px（小屏）
 * =========================================================== */

/* ---------- 拍照组件 ---------- */
.cam-box{ margin-bottom:14px; }
.cam-empty{
  border:1.5px dashed #CBD5E1; border-radius:14px; background:#FBFCFE;
  padding:26px 16px; text-align:center; cursor:pointer; transition:.16s;
}
.cam-empty:hover{ border-color:var(--primary); background:var(--primary-soft); }
.cam-ico{ font-size:30px; line-height:1; }
.cam-tip{ font-size:13.5px; font-weight:600; margin-top:8px; }
.cam-sub{ font-size:11.5px; color:var(--muted); margin-top:3px; }
.cam-shot[hidden], .cam-empty[hidden]{ display:none; }
.cam-shot img{ width:100%; max-height:340px; object-fit:contain; border-radius:12px; background:#0B1220; display:block; }
.cam-acts{ display:flex; align-items:center; gap:12px; margin-top:8px; flex-wrap:wrap; }
.cam-enh{ display:inline-flex; align-items:center; gap:6px; font-size:12.5px; color:var(--ink2); cursor:pointer; }
.cam-enh input{ width:15px; height:15px; accent-color:var(--primary); }
.btn-block{ width:100%; margin-top:8px; }

/* ---------- 考勤打卡 ---------- */
.att-hero{
  display:grid; grid-template-columns:1fr auto; gap:22px; align-items:center;
  padding:22px 24px; background:linear-gradient(135deg,#0F172A 0%,#1E2B45 58%,#243A63 100%);
  color:#fff; border:none;
}
.att-time{ font-size:34px; font-weight:700; letter-spacing:-1px; font-variant-numeric:tabular-nums; }
.att-date{ font-size:13px; color:#9FB0C9; margin-top:2px; }
.att-loc{ font-size:12.5px; color:#C7D4E8; margin-top:10px; }
.att-acts{ display:flex; gap:12px; }
.att-btn{
  width:120px; height:120px; border-radius:22px; background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.16); color:#fff; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:3px; transition:.18s;
}
.att-btn .ico{ font-size:20px; }
.att-btn b{ font-size:15px; font-weight:600; }
.att-btn i{ font-size:11px; color:#A9B7CE; font-style:normal; }
.att-btn:hover:not(:disabled){ background:rgba(255,255,255,.16); transform:translateY(-2px); }
.att-btn.done{ background:rgba(14,159,110,.22); border-color:rgba(14,159,110,.5); cursor:default; }
.att-btn:disabled{ cursor:default; }

.att-loc-box{
  display:flex; gap:12px; align-items:flex-start; padding:13px 15px; border-radius:12px;
  border:1px solid var(--line); background:#FBFCFE; margin-bottom:14px;
}
.att-loc-box b{ font-size:13.5px; }
.att-loc-box p{ font-size:12px; color:var(--muted); margin-top:2px; }
.att-loc-box.ok{ border-color:#BFE9D8; background:var(--green-soft); }
.att-loc-box.field{ border-color:#F5D9A8; background:var(--amber-soft); }
.att-loc-box.warn{ border-color:#F6C9C9; background:var(--red-soft); }
.att-loc-dot{ width:10px; height:10px; border-radius:50%; background:var(--green); margin-top:5px; flex:0 0 10px; }
.att-loc-box.field .att-loc-dot{ background:var(--amber); }
.att-loc-box.warn .att-loc-dot{ background:var(--red); }
.att-loc-spin{
  width:14px; height:14px; border-radius:50%; border:2px solid #D6E0EE; border-top-color:var(--primary);
  animation:spin .8s linear infinite; margin-top:3px; flex:0 0 14px;
}
@keyframes spin{ to{ transform:rotate(360deg); } }
.mono{ font-family:"SFMono-Regular",Menlo,Consolas,monospace; }

.att-list{ padding:4px 0; }
.att-row{
  display:grid; grid-template-columns:64px 1fr 70px; gap:14px; align-items:center;
  padding:12px 18px; border-bottom:1px solid var(--line);
}
.att-row:last-child{ border-bottom:none; }
.att-d b{ font-size:13.5px; display:block; }
.att-d span{ font-size:11.5px; color:var(--muted); }
.att-p{ font-size:12.5px; color:var(--ink2); display:flex; flex-direction:column; gap:3px; }
.att-p .dot{ display:inline-block; width:6px; height:6px; border-radius:50%; margin-right:5px; }
.att-p .dot.in{ background:var(--green); }
.att-p .dot.out{ background:var(--primary); }
.att-h{ text-align:right; font-size:13.5px; font-weight:600; }
.att-h span{ display:block; font-size:11px; color:var(--amber); font-weight:500; }

/* ---------- 二维码 ---------- */
.qr-wrap{ display:inline-block; padding:14px; background:#fff; border:1px solid var(--line); border-radius:14px; }
.qr-wrap img, .qr-wrap canvas{ display:block; }

/* ---------- 底部导航 ---------- */
.m-tabbar{
  position:fixed; left:0; right:0; bottom:0; z-index:60;
  display:flex; background:rgba(255,255,255,.96); backdrop-filter:blur(12px);
  border-top:1px solid var(--line); padding:6px 4px calc(6px + env(safe-area-inset-bottom));
}
.m-tab{
  flex:1; display:flex; flex-direction:column; align-items:center; gap:1px;
  padding:5px 0; color:var(--muted); font-size:10.5px;
}
.m-tab span{ font-size:19px; line-height:1.1; }
.m-tab b{ font-weight:500; }
.m-tab.on{ color:var(--primary); }
.m-tab.on b{ font-weight:600; }

/* ---------- 侧栏遮罩 ---------- */
.sb-mask{ position:fixed; inset:0; background:rgba(15,23,42,.42); z-index:70; animation:fade .16s; }
@keyframes fade{ from{ opacity:0 } to{ opacity:1 } }

/* ===========================================================
 *  ≤900px：单列 + 抽屉侧栏 + 表格卡片化
 * =========================================================== */
@media (max-width: 900px){
  .layout{ grid-template-columns:1fr; }
  .main, #page, .page, .card{ min-width:0; }
  .page{ overflow-x:hidden; }
  img{ max-width:100%; }
  .layout{ grid-template-columns:1fr; }
  .sidebar{
    position:fixed; left:0; top:0; bottom:0; width:262px; z-index:80;
    transform:translateX(-100%); transition:transform .22s ease; height:100vh; overflow-y:auto;
  }
  .sidebar.open{ transform:translateX(0); box-shadow:0 0 40px rgba(0,0,0,.28); }
  .topbar{ padding:10px 14px; }
  .topbar [data-act="toggle-side"]{ display:inline-flex !important; }
  .topbar .crumb span{ display:none; }
  .topbar .user-chip .rl{ display:none; }
  .page{ padding:14px 12px 84px; }
  .page-hd{ flex-direction:column; align-items:stretch; gap:10px; margin-bottom:14px; }
  .page-hd .actions{ flex-wrap:wrap; }
  .page-hd .actions .btn{ flex:1 1 auto; }
  .page-hd h2{ font-size:18px; }
  .page-hd p{ font-size:12.5px; }

  .grid.g-4, .grid.g-3{ grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .grid.g-2{ grid-template-columns:1fr; }
  .stat{ padding:13px 14px; }
  .stat .v{ font-size:22px; }
  .card{ border-radius:12px; }
  .card-hd{ padding:13px 14px; flex-wrap:wrap; gap:8px; }
  .card-hd .input{ width:100% !important; }

  .form-2col{ grid-template-columns:1fr; }

  /* 弹窗全屏（bottom sheet）：层级必须高于底部导航，底部留出安全区 */
  .mask{ padding:0; align-items:flex-end; z-index:600; }
  .modal, .modal.wide{
    max-width:100%; width:100%; max-height:calc(100vh - 12px); max-height:calc(100dvh - 12px);
    border-radius:18px 18px 0 0; margin:0; animation:slideUp .22s;
    padding-bottom:0;
  }
  /* 底部按钮常驻可见：内容再长也只滚动正文区 */
  @keyframes slideUp{ from{ transform:translateY(24px); opacity:.6 } to{ transform:none; opacity:1 } }
  .modal-hd{ padding:14px 16px; }
  .modal-bd{ padding:16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .modal-ft{ padding:12px 16px calc(12px + env(safe-area-inset-bottom)); flex-wrap:wrap; flex:0 0 auto; }
  .modal-ft .btn{ flex:1 1 auto; min-height:42px; }
  .modal-ft .grow{ display:none; }

  /* 表格 → 卡片 */
  .table{ display:block; }
  .table thead{ display:none; }
  .table tbody{ display:block; }
  .table tbody tr{
    display:block; border:1px solid var(--line); border-radius:12px;
    margin:0 0 10px; padding:6px 12px; background:#fff;
  }
  .table tbody tr:hover{ background:#fff; }
  .table td{
    display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
    padding:7px 0; border-bottom:1px dashed var(--line); font-size:13px; text-align:left !important;
  }
  .table td:last-child{ border-bottom:none; }
  .table td::before{
    content:attr(data-l); flex:0 0 78px; color:var(--muted); font-size:12px;
    font-weight:400; line-height:1.7;
  }
  .table td:empty{ display:none; }
  .table td[data-l=""]::before{ content:''; flex:0; }
  .table td > .btn{ margin-left:4px; }

  /* 花名册部门分组头：保持整条横栏，不参与卡片化 */
  .table tbody tr.emp-grp{ display:block; padding:0; margin:12px 0 8px; border:1px solid #E3EAF5; background:#F7F9FC; border-radius:10px; }
  .table tbody tr.emp-grp:hover{ background:#F7F9FC; }
  .table tbody tr.emp-grp td{ display:block; padding:10px 12px !important; border-bottom:none; }
  .table tbody tr.emp-grp td::before{ content:none; }
  .emp-grp-cell{ gap:7px; }
  .emp-grp-cell .gprev{ font-size:11.5px; }

  /* 页签横向滚动 */
  .tabs{ overflow-x:auto; max-width:100% !important; }
  .tabs button{ flex:0 0 auto; padding:0 12px; min-width:76px; }

  /* 考勤 */
  .att-hero{ grid-template-columns:1fr; gap:16px; padding:18px; }
  .att-time{ font-size:30px; }
  .att-acts{ width:100%; }
  .att-btn{ flex:1; width:auto; height:104px; border-radius:16px; }
  .att-row{ padding:11px 14px; grid-template-columns:56px 1fr 58px; gap:10px; }

  /* 文件模块 */
  .mfiles{ grid-template-columns:1fr !important; }
  .ftree{
    display:flex; gap:8px; overflow-x:auto; padding:10px 12px; white-space:nowrap;
    border-radius:12px; align-items:center;
  }
  .ftree .ftree-hd{ display:none; }
  .fnode{ flex:0 0 auto; border-radius:999px; border:1px solid var(--line); padding:5px 12px !important; margin:0; }
  .fnode .fc{ display:none; }

  /* 输入控件放大，避免 iOS 自动缩放 */
  .input, .select, .textarea{ font-size:16px; }
  .btn{ min-height:40px; }
  .btn-sm{ min-height:32px; }
}

@media (max-width: 560px){
  .grid.g-4, .grid.g-3{ grid-template-columns:1fr 1fr; }
  .page{ padding:12px 10px 84px; }
  .stat .d{ font-size:11.5px; }
  .att-time{ font-size:26px; }
  .att-btn{ height:96px; }
  .att-btn b{ font-size:14px; }
  .m-tab span{ font-size:18px; }
}

/* ---- 即时消息：窄屏单列（会话列表与线程上下堆叠） ---- */
@media (max-width: 900px){
  .chat-grid{ grid-template-columns:1fr !important; }
  .chat-grid > .chat-list-card{ max-height:220px; }
  /* 收起后整块隐藏，把整屏留给对话；线程头部有 ☰ 可以再展开 */
  .chat-grid.folded > .chat-list-card{ display:none; }
  .chat-grid.folded .chat-thread-card{ max-height:calc(100vh - 210px); }
  .chat-list-hd{ font-size:11.5px; }
}

/* ---------------- 扫描写切边编辑器 ---------------- */
.cam-edit{ margin-top:10px; border:1px solid var(--line); border-radius:14px; padding:10px; background:#FBFCFE; }
.cam-stage{ background:#0B1220; border-radius:12px; overflow:hidden; display:flex; justify-content:center; }
.cam-stage canvas{ display:block; max-width:100%; touch-action:none; cursor:crosshair; }
.cam-tools{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-top:10px; }
.cam-sep{ width:1px; height:22px; background:var(--line); margin:0 2px; }
.chip{ padding:5px 12px; border-radius:999px; border:1px solid var(--line); background:#fff; font-size:12.5px; color:var(--ink2); transition:.15s; }
.chip.on{ background:var(--primary-soft); border-color:var(--primary); color:var(--primary); font-weight:600; }
.cam-edit .cam-sub{ margin-top:8px; font-size:12px; color:var(--muted); text-align:center; }

/* ---------------- 上传选择区（手机端三入口） ---------------- */
.up-pick-btns{ display:flex; gap:8px; }
.up-pick-btns .btn{ flex:1; margin:0; height:44px; }

/* ---- 键盘弹起：底栏让位，聊天卡片贴在键盘上方（--kbh 由 app.js 写入） ---- */
.chat-thread-card{ transition:max-height .16s ease; }
body.kb-open .m-tabbar{ display:none !important; }
body.kb-open .page{ padding-bottom:10px !important; }
@media (max-width:900px){
  /* 兜底：即使脚本没算出行内高度，也按可视高度收缩，避免被键盘整块盖住 */
  body.kb-open .chat-grid.folded .chat-thread-card{
    max-height:calc(100dvh - var(--kbh,0px) - 120px);
  }
  body.kb-open .chat-thread-body{ padding-bottom:6px; }
}

/* ---------- 「我的」页面 ---------- */
.me-page{ max-width: 640px; }
.me-hero{
  display: flex; align-items: center; gap: 16px; padding: 22px 20px;
  background: linear-gradient(135deg,#0F172A 0%,#1E2B45 58%,#243A63 100%);
  color: #fff; border: none; cursor: pointer; margin-bottom: 14px;
}
.me-hero .avatar{ flex: 0 0 auto; box-shadow: 0 0 0 3px rgba(255,255,255,.14); }
.me-id{ min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.me-id b{ font-size: 18px; font-weight: 700; }
.me-id span{ font-size: 13px; color: #C7D4E8; }
.me-id i{ font-size: 11.5px; color: #8FA2C0; font-style: normal; margin-top: 3px; }
.me-kvs{ padding: 6px 16px 12px; }
.me-kv{
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 2px; border-bottom: 1px dashed var(--line); font-size: 13.5px;
}
.me-kv:last-child{ border-bottom: none; }
.me-kv span{ color: var(--muted); flex: 0 0 56px; }
.me-kv b{ font-weight: 500; text-align: right; word-break: break-all; }
.me-acts{ display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.me-act{ justify-content: flex-start; border: none; min-height: 46px; }
.me-act:hover{ background: var(--primary-soft); }
