/* ============================================================
 * EHS 安全生产管理平台 —— 前端原型样式
 * 主色：#D3222A（紫）  主题：Light
 * ============================================================ */

:root {
  --primary: #D3222A;
  --primary-dark: #A81C22;
  --primary-light: #E8474E;
  --primary-50: #FDECEC;
  --sidebar-bg: #1C1F24;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --border: #E9E9F0;
  --border-strong: #DADAE4;
  --text: #1F1F2E;
  --text-2: #5B5B6E;
  --text-3: #9090A3;
  --ok: #16A34A;   --ok-bg: #E8F7EE;
  --warn: #D97706; --warn-bg: #FFF4E3;
  --danger: #DC2626; --danger-bg: #FDECEC;
  --info: #2563EB;  --info-bg: #EBF2FE;
  --muted: #6B7280; --muted-bg: #F1F2F6;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(31, 31, 46, .06);
  --shadow-lg: 0 8px 28px rgba(31, 31, 46, .14);
  --font: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 224px; flex: 0 0 224px;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  color: #fff;
}
.sb-logo {
  height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sb-logo .mark {
  height: 32px; width: auto; flex: 0 0 auto;
  display: block;
}
.sb-logo .txt { font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.sb-logo .sub { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 1px; }

.sb-nav { flex: 1; overflow-y: auto; padding: 10px 0 20px; }
.sb-nav::-webkit-scrollbar { width: 4px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 2px; }
.nav-group { padding: 12px 18px 6px; font-size: 11px; color: rgba(255,255,255,.38); letter-spacing: .6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 18px; font-size: 13px; color: rgba(255,255,255,.72);
  cursor: pointer; position: relative; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 500; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; background: #fff; border-radius: 0 2px 2px 0;
}
.nav-item .ic { width: 16px; height: 16px; opacity: .85; flex: 0 0 16px; }
.nav-item .badge-n {
  margin-left: auto; background: #E8453C; color: #fff; font-size: 10px;
  padding: 1px 5px; border-radius: 8px; min-width: 16px; text-align: center;
}
.sb-foot {
  padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: rgba(255,255,255,.42); line-height: 1.6;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 56px; flex: 0 0 56px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
}
.tb-title { font-size: 15px; font-weight: 600; }
.tb-crumb { font-size: 12px; color: var(--text-3); }
.tb-spacer { flex: 1; }
.tb-company {
  display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px;
}
.tb-icon {
  width: 30px; height: 30px; border-radius: 50%; background: var(--muted-bg);
  display: flex; align-items: center; justify-content: center; position: relative;
  color: var(--text-2); font-size: 13px;
}
.tb-icon .dot {
  position: absolute; top: 5px; right: 5px; width: 7px; height: 7px;
  background: #E8453C; border-radius: 50%; border: 1.5px solid #fff;
}
.tb-user { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.tb-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px;
}

.content { flex: 1; overflow-y: auto; padding: 18px 20px 40px; }
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb { background: #D8D8E2; border-radius: 4px; }

/* ---------- 通用块 ---------- */
.page-head { display: flex; align-items: flex-end; margin-bottom: 16px; gap: 12px; }
.page-head h2 { font-size: 18px; font-weight: 600; letter-spacing: -.2px; }
.page-head .desc { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-hd {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-hd h3 { font-size: 14px; font-weight: 600; }
.card-hd .sub { font-size: 12px; color: var(--text-3); }
.card-hd .more { margin-left: auto; font-size: 12px; color: var(--primary); }
.card-bd { padding: 16px; }
.card-bd.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-2-1, .g-1-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .g3 { grid-template-columns: 1fr; } }

.mb14 { margin-bottom: 14px; }
.mt14 { margin-top: 14px; }
.flex { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.mla { margin-left: auto; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }

/* ---------- KPI ---------- */
.kpi { padding: 16px; }
.kpi .label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -.6px; margin: 8px 0 4px; }
.kpi .foot { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.delta { font-size: 11px; padding: 1px 5px; border-radius: 4px; }
.delta.up { color: var(--ok); background: var(--ok-bg); }
.delta.down { color: var(--danger); background: var(--danger-bg); }
.delta.good { color: var(--ok); background: var(--ok-bg); }

/* ---------- 按钮 ---------- */
.btn {
  height: 30px; padding: 0 13px; border-radius: 6px; font-size: 12.5px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary-light); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.ghost { background: var(--primary-50); border-color: transparent; color: var(--primary); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: #F3C9C9; }
.btn.danger:hover { background: var(--danger-bg); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th {
  text-align: left; font-weight: 500; color: var(--text-2);
  background: #FAFAFC; padding: 9px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap; font-size: 12px;
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid #F2F2F6; color: var(--text); vertical-align: middle; }
table.tbl tbody tr:hover { background: #FBFAFE; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .mono { font-family: "SF Mono", Consolas, monospace; font-size: 11.5px; color: var(--text-2); }
table.tbl .link { color: var(--primary); cursor: pointer; }
table.tbl .link:hover { text-decoration: underline; }
.tbl-empty { padding: 40px; text-align: center; color: var(--text-3); font-size: 12.5px; }

/* ---------- 徽标 / 状态 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px; font-size: 11.5px; white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.danger { color: var(--danger); background: var(--danger-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.muted { color: var(--muted); background: var(--muted-bg); }
.badge.purple { color: var(--primary); background: var(--primary-50); }
.badge .dotc { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.tag {
  padding: 1px 6px; border-radius: 4px; font-size: 11px;
  background: var(--muted-bg); color: var(--text-2); white-space: nowrap;
}
.tag.ai { background: var(--primary-50); color: var(--primary); }

/* ---------- 筛选栏 ---------- */
.filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: #FCFCFE;
}
.seg { display: inline-flex; background: var(--muted-bg); border-radius: 6px; padding: 2px; }
.seg button {
  padding: 4px 11px; font-size: 12px; border-radius: 4px; color: var(--text-2);
}
.seg button.on { background: #fff; color: var(--primary); font-weight: 500; box-shadow: var(--shadow); }
.input, .select {
  height: 30px; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 0 10px; font-size: 12.5px; font-family: inherit; color: var(--text); background: #fff;
  outline: none; min-width: 130px;
}
.input:focus, .select:focus { border-color: var(--primary-light); }
.input.search { min-width: 200px; }

/* ---------- 抽屉 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(24, 24, 38, .38); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.mask.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 620px; max-width: 94vw;
  background: #fff; z-index: 100; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .26s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.on { transform: translateX(0); }
.drawer.wide { width: 860px; }
.dw-hd {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.dw-hd h3 { font-size: 15px; font-weight: 600; }
.dw-close { margin-left: auto; font-size: 20px; color: var(--text-3); line-height: 1; width: 28px; height: 28px; }
.dw-close:hover { color: var(--text); }
.dw-bd { flex: 1; overflow-y: auto; padding: 18px 20px; }
.dw-ft {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; background: #FCFCFE;
}

/* ---------- 详情描述列表 ---------- */
.dl { display: grid; grid-template-columns: 96px 1fr; gap: 10px 14px; font-size: 12.5px; }
.dl dt { color: var(--text-3); }
.dl dd { color: var(--text); }
.dl.full { grid-template-columns: 1fr; }
.sec-title {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  padding: 0 0 10px; margin: 18px 0 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.sec-title:first-child { margin-top: 0; }
.sec-title .num {
  width: 18px; height: 18px; border-radius: 50%; background: var(--primary-50);
  color: var(--primary); font-size: 11px; display: flex; align-items: center; justify-content: center;
}

/* ---------- 时间轴 ---------- */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border-strong);
}
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: -19px; top: 4px;
  width: 9px; height: 9px; border-radius: 50%; background: #fff;
  border: 2px solid var(--border-strong);
}
.tl-item.done::before { border-color: var(--ok); background: var(--ok); }
.tl-item.now::before { border-color: var(--primary); background: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.tl-item.warn::before { border-color: var(--warn); background: var(--warn); }
.tl-t { font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.tl-d { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.6; }

/* ---------- 流程步骤条 ---------- */
.steps { display: flex; align-items: center; gap: 0; padding: 6px 0 2px; }
.step { display: flex; align-items: center; }
.step .cir {
  width: 22px; height: 22px; border-radius: 50%; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--muted-bg); color: var(--text-3); flex: 0 0 22px;
}
.step.done .cir { background: var(--ok); color: #fff; }
.step.now .cir { background: var(--primary); color: #fff; box-shadow: 0 0 0 3px var(--primary-50); }
.step .nm { font-size: 12px; margin-left: 6px; color: var(--text-2); }
.step.done .nm { color: var(--text); }
.step.now .nm { color: var(--primary); font-weight: 500; }
.step .bar { width: 34px; height: 1px; background: var(--border-strong); margin: 0 8px; }
.step.done .bar { background: var(--ok); }

/* ---------- 组织树 ---------- */
.tree { font-size: 12.5px; }
.tree-node { display: flex; align-items: center; gap: 7px; padding: 5px 0; }
.tree-node .caret {
  width: 14px; height: 14px; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 9px; cursor: pointer; transition: transform .15s;
}
.tree-node .caret.open { transform: rotate(90deg); }
.tree-children { padding-left: 21px; border-left: 1px dashed var(--border-strong); margin-left: 6px; }
.tree-label { display: flex; align-items: center; gap: 7px; }
.tree-label .nm { font-weight: 500; }
.tree-label .cnt { color: var(--text-3); font-size: 11.5px; }

/* ---------- 权限矩阵 ---------- */
.matrix { font-size: 11.5px; }
.matrix th, .matrix td { padding: 7px 8px; border-bottom: 1px solid #F2F2F6; text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .yes { color: var(--ok); }
.matrix .no { color: #D5D5DE; }

/* ---------- 二维码占位 ---------- */
.qr {
  width: 92px; height: 92px; border: 1px solid var(--border);
  border-radius: 6px; padding: 6px; background: #fff; flex: 0 0 92px;
}
.qr svg { display: block; width: 100%; height: 100%; }

/* ---------- 手机模拟 ---------- */
.phone {
  width: 288px; border: 8px solid #22222C; border-radius: 30px;
  background: #fff; overflow: hidden; box-shadow: var(--shadow-lg);
  flex: 0 0 288px; position: relative;
}
.phone .notch {
  height: 20px; background: #22222C; border-radius: 0 0 12px 12px;
  margin: 0 auto; width: 108px; position: relative; z-index: 2;
}
.phone .screen { height: 560px; overflow-y: auto; background: #F7F7FA; }
.phone .screen::-webkit-scrollbar { width: 0; }
.ph-hd {
  background: var(--primary); color: #fff; padding: 12px 14px 14px;
}
.ph-hd .t { font-size: 14px; font-weight: 600; }
.ph-hd .s { font-size: 11.5px; opacity: .8; margin-top: 2px; }
.ph-card { background: #fff; border-radius: 10px; padding: 12px; margin: 10px; box-shadow: var(--shadow); }
.ph-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 4px 10px 10px; }
.ph-ic { text-align: center; }
.ph-ic .box {
  width: 44px; height: 44px; border-radius: 12px; margin: 0 auto 5px;
  display: flex; align-items: center; justify-content: center;
}
.ph-ic .lb { font-size: 10.5px; color: var(--text-2); }
.ph-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #F2F2F6; }
.ph-row:last-child { border-bottom: none; }
.ph-scan {
  margin: 10px; height: 168px; border-radius: 10px; background: #22222C;
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.ph-scan .frame {
  width: 120px; height: 120px; border: 2px solid #4CD964; border-radius: 8px; position: relative;
}
.ph-scan .line {
  position: absolute; left: 6px; right: 6px; height: 2px; background: #4CD964;
  animation: scanline 1.8s ease-in-out infinite;
}
@keyframes scanline { 0% { top: 6px; } 50% { top: 108px; } 100% { top: 6px; } }
.ph-scan .tip { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: rgba(255,255,255,.7); font-size: 11px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 70px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: 6px; padding: 10px 14px; font-size: 12.5px; box-shadow: var(--shadow-lg);
  min-width: 220px; animation: toastIn .22s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- 图表 ---------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* ---------- 进度条 ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; font-size: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-row .nm { width: 76px; color: var(--text-2); flex: 0 0 76px; }
.bar-track { flex: 1; height: 7px; background: var(--muted-bg); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--primary); }
.bar-row .val { width: 40px; text-align: right; color: var(--text-2); flex: 0 0 40px; }

/* ---------- 列表（消息/待办） ---------- */
.list-item {
  display: flex; gap: 10px; padding: 11px 16px; border-bottom: 1px solid #F2F2F6; align-items: flex-start;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #FBFAFE; }
.list-item .ic {
  width: 26px; height: 26px; border-radius: 6px; flex: 0 0 26px;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.list-item .tt { font-size: 12.5px; font-weight: 500; }
.list-item .ds { font-size: 11.5px; color: var(--text-3); margin-top: 2px; line-height: 1.55; }
.list-item .tm { font-size: 11px; color: var(--text-3); margin-left: auto; flex: 0 0 auto; }

/* ---------- 空状态 / 提示条 ---------- */
.notice {
  display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px;
  border-radius: 6px; font-size: 12.5px; line-height: 1.6;
  background: var(--primary-50); color: var(--primary-dark); border: 1px solid #F5C9CB;
}
.notice.warn { background: var(--warn-bg); color: #8A5300; border-color: #F3DFB8; }
.notice.danger { background: var(--danger-bg); color: #9B1C1C; border-color: #F5CFCF; }

/* ---------- AI 识别演示 ---------- */
.ai-box {
  border: 1px dashed var(--primary-light); border-radius: 8px;
  background: linear-gradient(180deg, #FBFAFF 0%, #F6F4FF 100%); padding: 14px;
}
.ai-shot {
  height: 150px; border-radius: 6px; background: #2E2E3A; position: relative;
  display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.45); font-size: 12px;
}
.ai-shot .wm {
  position: absolute; right: 8px; bottom: 8px; font-size: 10px; color: rgba(255,255,255,.6);
}
.ai-res { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border-strong); }
.ai-res:last-child { border-bottom: none; }
.conf { font-size: 11px; color: var(--text-3); font-family: Consolas, monospace; }

/* ---------- 大屏 ---------- */
.screen-page { background: #F5F6F8; margin: -18px -20px -40px; padding: 18px 20px 24px; }
.big-title {
  text-align: center; font-size: 20px; font-weight: 600; letter-spacing: 1px;
  padding: 4px 0 16px; color: var(--primary-dark);
}
.big-kpi { text-align: center; padding: 14px; }
.big-kpi .v { font-size: 30px; font-weight: 600; color: var(--primary); letter-spacing: -.8px; }
.big-kpi .l { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* ============================================================
 * 移动端 / 响应式适配
 * 断点：≤1024（平板竖屏） · ≤768（手机） · ≤420（小屏手机）
 * 目标：iPhone / Android 微信内置浏览器、Chrome / Safari 均可用
 * ============================================================ */

/* 全局：关闭点击高亮，优化触摸滚动 */
html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }

/* 移动端菜单按钮（桌面端隐藏） */
.tb-menu {
  display: none; width: 34px; height: 34px; border-radius: 8px;
  align-items: center; justify-content: center; color: var(--text-2);
  background: var(--muted-bg); flex: 0 0 34px; margin-right: 2px;
}
.tb-menu:active { background: var(--border); }

/* 侧边栏遮罩（默认隐藏） */
.sb-mask {
  display: none; position: fixed; inset: 0; z-index: 95;
  background: rgba(24, 24, 38, .45);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
body.sb-open .sb-mask { opacity: 1; pointer-events: auto; }

/* ---------- 平板及以下（≤1024px） ---------- */
@media (max-width: 1024px) {
  .grid > * { min-width: 0; }        /* 防止表格/图表把栅格列撑破 */
  .card { min-width: 0; overflow: hidden; }
  .content { padding: 16px 16px 36px; }
  .page-head h2 { font-size: 17px; }
  .card-hd { padding: 12px 14px; }
  .card-bd { padding: 14px; }
  .filters { padding: 10px 14px; }
  .dw-bd { padding: 16px; }
  .dw-hd, .dw-ft { padding-left: 16px; padding-right: 16px; }
  .kpi .value { font-size: 24px; }
  .screen-page { margin: -16px -16px -36px; padding: 16px; }
}

/* ---------- 手机（≤768px） ---------- */
@media (max-width: 768px) {
  /* --- 骨架：侧边栏抽屉化 --- */
  .app { height: 100vh; height: 100dvh; }  /* dvh 兼容移动端浏览器地址栏收缩 */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 96;
    width: 250px; flex: none;
    transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 0 0 24px rgba(0, 0, 0, .3);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.sb-open .sidebar { transform: translateX(0); }
  .sb-mask { display: block; }
  .tb-menu { display: flex; }

  /* --- 顶栏精简 --- */
  .topbar {
    height: 52px; flex: 0 0 52px; padding: 0 12px; gap: 10px;
    padding-top: env(safe-area-inset-top);
    height: calc(52px + env(safe-area-inset-top));
    flex-basis: calc(52px + env(safe-area-inset-top));
  }
  .topbar .tb-company { display: none; }
  .topbar .tb-crumb { display: none; }
  .tb-title { font-size: 14.5px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tb-user > div { display: none; }         /* 手机上隐藏用户名文字，只留头像 */
  .tb-avatar { width: 30px; height: 30px; font-size: 13px; }
  #tb-user-box { gap: 0; }
  #tb-quit { margin-left: 6px; padding: 6px 4px; font-size: 11.5px; }  /* 保留退出入口，仅缩小 */

  /* --- 内容区 --- */
  .content { padding: 12px 12px calc(28px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
  .page-head { display: block; margin-bottom: 12px; }
  .page-head h2 { font-size: 18px; }
  .page-head .desc { font-size: 11.5px; line-height: 1.6; margin-top: 4px; }
  .page-head .actions {
    margin-left: 0; margin-top: 12px; display: flex; gap: 8px;
    overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch;
  }
  .page-head .actions::-webkit-scrollbar { height: 0; }

  /* --- 网格全部单列，KPI 保持两列；minmax(0,1fr) 防止内部表格把列撑破 --- */
  .grid { gap: 10px; }
  .grid > * { min-width: 0; }
  .g2, .g3, .g-2-1, .g-1-2 { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

  /* --- 卡片：超出部分交给内部 .tbl-wrap 横向滚动 --- */
  .card { border-radius: 10px; min-width: 0; overflow: hidden; }
  .card-bd { min-width: 0; overflow: hidden; }
  .card-hd { padding: 11px 12px; flex-wrap: wrap; row-gap: 6px; }
  .card-hd h3 { font-size: 13.5px; }
  .card-hd .sub { flex-basis: 100%; }
  .card-hd .more { margin-left: auto; }
  .card-bd { padding: 12px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 21px; margin: 6px 0 3px; }
  .kpi .label { font-size: 11.5px; }
  .kpi .foot { font-size: 10.5px; }

  /* --- 筛选栏：纵向排布，控件撑满 --- */
  .filters { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .filters .input, .filters .select, .filters .input.search { min-width: 0; width: 100%; }
  .filters .mla { margin-left: 0; }
  .seg { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .seg::-webkit-scrollbar { height: 0; }
  .seg button { flex: 1 0 auto; padding: 6px 12px; }

  /* --- 表单控件：触摸友好 + 16px 防 iOS 自动放大 --- */
  /* Apple HIG 建议触摸目标 ≥44px，此处取 40px 兼顾信息密度 */
  .input, .select { height: 40px; font-size: 16px; min-width: 0; border-radius: 8px; }
  .btn { height: 40px; padding: 0 14px; font-size: 13.5px; border-radius: 8px; }
  .btn.sm { height: 34px; padding: 0 11px; }
  .seg button { padding: 7px 13px; }
  .dw-close { width: 40px; height: 40px; font-size: 26px; }

  /* --- 表格：横向滚动 + 触摸滚动条 + 右侧渐隐提示（告知用户可左右滑动） --- */
  .tbl-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .card-bd.flush { position: relative; }
  .card-bd.flush::after {
    content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 20px; pointer-events: none;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .92));
  }
  .tbl-wrap::-webkit-scrollbar { height: 6px; }
  .tbl-wrap::-webkit-scrollbar-thumb { background: #CDCDD8; border-radius: 3px; }
  table.tbl { min-width: 640px; font-size: 12px; }
  table.tbl th { padding: 10px 10px; font-size: 11.5px; position: sticky; top: 0; z-index: 1; }
  table.tbl td { padding: 11px 10px; }
  table.tbl .link { display: inline-block; padding: 4px 0; }
  .tbl-empty { padding: 32px 16px; font-size: 12px; }

  /* --- 抽屉：手机全屏 --- */
  .drawer { width: 100%; max-width: 100%; top: 0; }
  .drawer.wide { width: 100%; }
  .dw-hd { padding: 14px 14px; padding-top: calc(14px + env(safe-area-inset-top)); }
  .dw-hd h3 { font-size: 14.5px; max-width: calc(100% - 48px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dw-bd { padding: 14px 14px 20px; }
  .dw-ft {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    position: sticky; bottom: 0; z-index: 2; gap: 10px;
    overflow-x: auto; justify-content: flex-start;   /* 按钮多时横向滚动，不丢功能 */
    -webkit-overflow-scrolling: touch;
  }
  .dw-ft::-webkit-scrollbar { height: 0; }
  .dw-ft .btn { flex: 0 0 auto; height: 42px; }

  /* --- 详情列表：手机上标签与值换行更清晰 --- */
  .dl { grid-template-columns: 88px 1fr; gap: 8px 10px; font-size: 12px; }

  /* --- 步骤条：横向滚动 --- */
  .steps { overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
  .steps::-webkit-scrollbar { height: 0; }
  .step .nm { white-space: nowrap; }

  /* --- 时间轴 / 通知 --- */
  .timeline { padding-left: 16px; }
  .tl-item::before { left: -15px; }
  .timeline::before { left: 4px; }

  /* --- AI 识别页 --- */
  .ai-box .ai-shot { height: 180px; }
  .ai-res { gap: 8px; align-items: flex-start; flex-wrap: wrap; }
  .ai-res .conf { flex-basis: 100%; padding-left: 0; }

  /* --- 大屏页：手机上改为纵向堆叠，避免被压缩 --- */
  .screen-page { margin: -12px -12px calc(-28px - env(safe-area-inset-bottom)); padding: 12px; }
  .big-title { font-size: 16px; padding-bottom: 12px; }
  .big-kpi { padding: 10px; }
  .big-kpi .v { font-size: 24px; }

  /* --- 手机模拟页：壳宽自适应 --- */
  .phone-wrap { max-width: 100%; }
  .ph-frame { max-width: 100%; }
}

/* ---------- 小屏手机（≤420px） ---------- */
@media (max-width: 420px) {
  .g4 { grid-template-columns: 1fr; }
  .kpi .value { font-size: 20px; }
  .tb-title { font-size: 14px; max-width: 40vw; }
  .page-head .actions .btn { padding: 0 11px; font-size: 13px; }
  .dl { grid-template-columns: 1fr; gap: 4px 0; }
  .dl dd { margin-bottom: 8px; }
  .drawer .dw-ft { flex-wrap: wrap; }
  .drawer .dw-ft .btn { flex: 1 1 100%; }
}

/* ---------- 横屏手机：压缩顶栏高度 ---------- */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 480px) {
  .topbar { height: 46px; flex: 0 0 46px; padding-top: 0; }
  .tb-title { max-width: 60vw; }
  .content { padding: 10px 12px 24px; }
  .kpi .value { font-size: 19px; }
}

/* ---------- 打印友好（导出二维码时不打印菜单按钮等） ---------- */
@media print {
  .tb-menu, .sb-mask, .topbar, .sidebar { display: none !important; }
}

/* ---------- 暗色 / 低电量无需额外处理，系统浅色主题保持一致 ---------- */

/* ============================================================
 * 企业级补强层（ops.js）配套样式
 * ============================================================ */

/* 通用文字链接：表格外也可用 */
.lnk { color: var(--primary); cursor: pointer; font-size: 12px; }
.lnk:hover { text-decoration: underline; }
.lnk.dg { color: var(--danger); }
.lnk + .lnk { margin-left: 8px; }
.lnk-wrap .lnk { font-size: 11.5px; }

/* 权限矩阵：部分授权 */
.matrix .half { color: var(--warn); }

/* 巡检表检查项编辑器 */
.fi-row .btn.danger { flex: 0 0 auto; }

/* 字典项 hover 高亮，便于点击编辑 */
.dict-item:hover { background: #FAFAFD; }
.dict-item .lnk { margin-left: 10px; }

/* 隐患照片缩略图容器 */
#hf-photos > div { flex: 0 0 auto; }
