/* ============================================================
   项目现场综合管理工具 · 全局样式
   ------------------------------------------------------------
   设计原则：
   1. 工地场景常用手机 + 强光，所有文字对比度都按 WCAG AA 标准留足余量
   2. 触控目标最小 44×44（安全区），戴手套也能点得准
   3. 移动端优先，桌面端用媒体查询增强
   ============================================================ */

:root {
  /* 主色：工地安全帽的工程黄，取深一档保证白字可读 */
  --primary: #1f6feb;
  --primary-dark: #1558bd;
  --primary-light: #e8f1ff;

  /* 语义色 */
  --success: #1a7f37;
  --success-bg: #e8f5ec;
  --warning: #b45309;
  --warning-bg: #fef3e2;
  --danger: #c0392b;
  --danger-bg: #fdeceb;
  --info: #0e7490;
  --info-bg: #e0f4f8;

  /* 中性色 */
  --text: #1f2328;          /* 正文，比纯黑柔和，长时间看不累 */
  --text-secondary: #57606a;
  --text-muted: #8b949e;
  --border: #d0d7de;
  --border-light: #e6e8eb;
  --bg: #f6f8fa;
  --bg-card: #ffffff;
  --sidebar-bg: #1c2530;
  --sidebar-text: #c9d1d9;
  --sidebar-active: #1f6feb;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 56px;
  --sidebar-w: 224px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }

/* ---------- 首屏骨架 ---------- */
.boot {
  height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
}
.boot-logo { font-size: 48px; animation: pulse 1.5s infinite; }
.boot-text { color: var(--text-muted); font-size: 14px; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ============================================================
   登录页
   ============================================================ */
.login-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #1c2530 0%, #2d3a4d 100%);
}
.login-box {
  width: 100%; max-width: 400px; background: #fff;
  border-radius: 12px; padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.login-title { text-align: center; margin-bottom: 6px; font-size: 20px; font-weight: 600; }
.login-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.login-tip {
  margin-top: 16px; padding: 10px 12px; background: var(--bg);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary);
  line-height: 1.8;
}
.login-tip b { color: var(--text); }

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

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .2s;
}
.sidebar.collapsed { width: 60px; }
.sidebar-logo {
  height: var(--header-h); display: flex; align-items: center; gap: 8px;
  padding: 0 16px; font-weight: 600; color: #fff; font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,.08); flex-shrink: 0;
}
.sidebar-logo .ico { font-size: 20px; }
.sidebar.collapsed .sidebar-logo span:not(.ico) { display: none; }
.sidebar-menu { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.menu-group-title {
  padding: 12px 16px 6px; font-size: 11px; color: #6e7681;
  text-transform: uppercase; letter-spacing: .5px;
}
.sidebar.collapsed .menu-group-title { display: none; }

.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: 40px; cursor: pointer;
  color: var(--sidebar-text); font-size: 14px;
  border-left: 3px solid transparent; transition: all .15s;
  white-space: nowrap; overflow: hidden;
}
.menu-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-item.active {
  background: rgba(31,111,235,.15); color: #fff;
  border-left-color: var(--sidebar-active);
}
.menu-item .ico { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }

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

.header {
  height: var(--header-h); flex-shrink: 0; background: #fff;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
}
.header-title { font-size: 16px; font-weight: 600; flex-shrink: 0; }
.header-spacer { flex: 1; }

.project-switch {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; background: var(--bg); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; max-width: 240px;
}
.project-switch:hover { background: var(--primary-light); }
.project-switch select {
  border: none; background: transparent; font-size: 13px;
  color: var(--text); cursor: pointer; max-width: 170px; outline: none;
}

.user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}

.content { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: #c8cdd3; border-radius: 3px; }

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.card-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 16px; }
.card-body.np { padding: 0; }

/* ============================================================
   统计卡片
   ============================================================ */
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 14px;
}
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); border-left: 3px solid var(--primary);
}
.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red { border-left-color: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 600; line-height: 1.3; }
.stat-value .unit { font-size: 13px; font-weight: 400; color: var(--text-muted); margin-left: 2px; }
.stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ============================================================
   表格
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 100%; }
table.tbl th {
  background: #f6f8fa; text-align: left; padding: 9px 12px;
  font-weight: 600; color: var(--text-secondary); white-space: nowrap;
  border-bottom: 1px solid var(--border-light);
  position: sticky; top: 0; z-index: 1;
}
table.tbl td {
  padding: 9px 12px; border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
table.tbl tbody tr:hover { background: #f8fafc; }
table.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .nowrap { white-space: nowrap; }
.tbl .actions { white-space: nowrap; }

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 32px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font-size: 13px; cursor: pointer; transition: all .15s; user-select: none;
  white-space: nowrap; min-height: 32px;
}
.btn:hover { border-color: #a8b0b8; background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { opacity: .9; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: .9; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; min-height: 26px; }
.btn-link {
  border: none; background: none; color: var(--primary);
  padding: 0 4px; height: auto; min-height: auto; font-size: 13px;
}
.btn-link:hover { background: none; text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

/* ============================================================
   表单
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-item { display: flex; flex-direction: column; gap: 5px; }
.form-item.full { grid-column: 1 / -1; }
.form-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; outline: none; transition: border-color .15s;
}
.textarea { height: auto; min-height: 68px; padding: 8px 10px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,111,235,.12);
}
.input:disabled, .select:disabled { background: #f6f8fa; color: var(--text-muted); }
.form-hint { font-size: 12px; color: var(--text-muted); }
.form-error { font-size: 12px; color: var(--danger); }

.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
}
.filter-item { display: flex; flex-direction: column; gap: 4px; }
.filter-item label { font-size: 12px; color: var(--text-muted); }
.filter-item .input, .filter-item .select { min-width: 130px; height: 32px; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }

/* ============================================================
   徽章
   ============================================================ */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; line-height: 18px; white-space: nowrap;
  background: var(--bg); color: var(--text-secondary);
}
.badge.blue { background: var(--primary-light); color: var(--primary-dark); }
.badge.green { background: var(--success-bg); color: var(--success); }
.badge.orange { background: var(--warning-bg); color: var(--warning); }
.badge.red { background: var(--danger-bg); color: var(--danger); }
.badge.cyan { background: var(--info-bg); color: var(--info); }

/* ============================================================
   弹窗
   ============================================================ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); width: 100%;
  max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 860px; }
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; font-weight: 600;
}
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal-close {
  margin-left: auto; border: none; background: none; font-size: 20px;
  color: var(--text-muted); cursor: pointer; line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

/* ============================================================
   提示
   ============================================================ */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px; line-height: 1.7;
  border-left: 3px solid;
}
.alert.info { background: var(--info-bg); border-color: var(--info); color: #0c5c73; }
.alert.warn { background: var(--warning-bg); border-color: var(--warning); color: #8a3f06; }
.alert.error { background: var(--danger-bg); border-color: var(--danger); color: #96271a; }
.alert.success { background: var(--success-bg); border-color: var(--success); color: #14612b; }

/* ★ 规则提示条：把甲方给的硬规则直接印在页面上，不藏在帮助文档里 */
.rule-note {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 13px; color: #92400e; margin-bottom: 14px; line-height: 1.8;
}
.rule-note b { color: #78350f; }

/* Toast */
.toast-wrap {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: max-content; max-width: 90vw;
}
.toast {
  padding: 9px 18px; border-radius: 20px; font-size: 13px;
  box-shadow: var(--shadow-lg); animation: toastIn .2s;
  background: #fff; border: 1px solid var(--border); color: var(--text);
}
.toast.success { background: var(--success); color: #fff; border-color: var(--success); }
.toast.error { background: var(--danger); color: #fff; border-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* 空状态 */
.empty { text-align: center; padding: 44px 20px; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 8px; opacity: .5; }

/* 分页 */
.pager {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; padding: 12px 16px; font-size: 13px;
  border-top: 1px solid var(--border-light); flex-wrap: wrap;
}
.pager .total { color: var(--text-muted); margin-right: auto; }
.pager .page-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--border); background: #fff;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.pager .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager .page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* 进度条 */
.progress-bar { height: 6px; background: var(--border-light); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; }
.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--warning); }

/* 图表容器 */
.chart { width: 100%; height: 280px; }

/* 时间线（审批进度） */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border-light);
}
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before {
  content: ''; position: absolute; left: -19px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff; border: 2px solid var(--border);
}
.tl-item.done::before { background: var(--success); border-color: var(--success); }
.tl-item.current::before { background: var(--primary); border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31,111,235,.2); }
.tl-item.reject::before { background: var(--danger); border-color: var(--danger); }
.tl-title { font-size: 14px; font-weight: 500; }
.tl-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tl-comment {
  font-size: 13px; color: var(--text-secondary); margin-top: 4px;
  padding: 6px 10px; background: var(--bg); border-radius: var(--radius-sm);
}

/* 加载 */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   移动端：底部导航 + 表格转卡片
   ============================================================ */
.mobile-tabs {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  height: 54px; background: #fff; border-top: 1px solid var(--border-light);
  z-index: 100; padding-bottom: var(--safe-bottom);
}
.mobile-tabs .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; font-size: 11px; color: var(--text-muted);
  cursor: pointer; gap: 2px; -webkit-tap-highlight-color: transparent;
}
.mobile-tabs .tab .ico { font-size: 19px; }
.mobile-tabs .tab.active { color: var(--primary); }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 12px; padding-bottom: 68px; }
  .mobile-tabs { display: flex; }
  .header { padding: 0 12px; }
  .header-title { font-size: 15px; }
  .project-switch { max-width: 130px; }
  .project-switch select { max-width: 90px; font-size: 12px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 11px 13px; }
  .stat-value { font-size: 18px; }
  .form-grid { grid-template-columns: 1fr; }

  /* 按钮加大，方便戴手套点 */
  .btn { height: 36px; padding: 0 16px; }
  .btn-sm { height: 30px; }

  .modal-mask { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; border-radius: 12px 12px 0 0; max-height: 92vh; }

  /* ★ 表格转卡片流：一行一条，不用横向滚动
     （工地上单手操作，横向滚表格是最难受的交互） */
  .table-wrap.card-mode table.tbl,
  .table-wrap.card-mode table.tbl tbody,
  .table-wrap.card-mode table.tbl tr,
  .table-wrap.card-mode table.tbl td { display: block; width: 100%; }
  .table-wrap.card-mode table.tbl thead { display: none; }
  .table-wrap.card-mode table.tbl tr {
    border: 1px solid var(--border-light); border-radius: var(--radius);
    margin: 8px; padding: 6px 4px; background: #fff; box-shadow: var(--shadow);
  }
  .table-wrap.card-mode table.tbl td {
    border: none; padding: 5px 12px;
    display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  }
  /* 每格前面显示字段名（由 td::before 注入） */
  .table-wrap.card-mode table.tbl td[data-label]::before {
    content: attr(data-label); color: var(--text-muted);
    font-size: 12px; flex-shrink: 0; font-weight: 400;
  }
  .table-wrap.card-mode table.tbl td.num { text-align: right; }
  .table-wrap.card-mode table.tbl td.actions {
    justify-content: flex-end; border-top: 1px solid var(--border-light);
    margin-top: 4px; padding-top: 8px;
  }
  .filter-bar { padding: 10px 12px; }
  .filter-item { flex: 1; min-width: 130px; }
  .filter-item .input, .filter-item .select { min-width: 0; width: 100%; }
  .filter-actions { width: 100%; margin-left: 0; }
  .filter-actions .btn { flex: 1; }
  .toast-wrap { top: 10px; }
}

/* 打印：报表导出时隐藏导航 */
@media print {
  .sidebar, .header, .mobile-tabs, .filter-bar, .pager, .btn { display: none !important; }
  .content { padding: 0; overflow: visible; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ---------- 消息铃铛（顶栏） ---------- */
.msg-bell {
  position: relative; display: flex; align-items: center; cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius-sm); font-size: 18px;
}
.msg-bell:hover { background: var(--bg); }
.msg-bell .badge {
  position: absolute; top: -2px; right: -2px; font-size: 11px;
  line-height: 16px; padding: 0 5px; min-width: 18px; text-align: center;
}

/* ============================================================
   系统管理页专用样式
   ============================================================ */

/* ---------- 二次确认框 ---------- */
.confirm-text {
  font-size: 15px; line-height: 1.7; color: var(--text);
}
.confirm-text.danger { color: var(--danger); font-weight: 600; }
.modal-sm { width: 420px; max-width: 92vw; }

/* ---------- 行内小按钮 ---------- */
.btn-xs {
  padding: 2px 8px; font-size: 12px; border-radius: 3px;
  margin-right: 4px; line-height: 1.6;
}
/* 表格操作列按钮太密时用这个包一层 */
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }

/* ---------- 状态标签 ---------- */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; line-height: 18px; background: var(--bg); color: var(--text-2);
}
.tag.green { background: var(--success-bg); color: var(--success); }
.tag.red { background: var(--danger-bg); color: var(--danger); }
.tag.orange { background: var(--warning-bg); color: var(--warning); }
.tag.gray { background: var(--bg); color: var(--text-3); }

/* ---------- 多选组（角色勾选） ---------- */
.check-group {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px;
  max-height: 180px; overflow-y: auto;
}
.check { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.check.inline { flex-shrink: 0; margin-left: 12px; color: var(--text-2); }

/* ---------- 项目授权列表 ---------- */
.grant-list {
  max-height: 380px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 4px;
}
.grant-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.grant-row:last-child { border-bottom: none; }
.grant-row:hover { background: var(--bg); }
.muted { color: var(--text-3); font-size: 12px; margin-left: 6px; }
.req { color: var(--danger); }

/* ---------- 表单栅格补齐 ---------- */
.form-item.full { grid-column: 1 / -1; }

/* ---------- 权限配置 ---------- */
.perm-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--bg); border-radius: 4px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.perm-summary .ok { color: var(--success); }
.perm-list {
  max-height: 420px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 4px;
}
.perm-group { border-bottom: 1px solid var(--border); }
.perm-group:last-child { border-bottom: none; }
.perm-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--bg);
  position: sticky; top: 0; z-index: 1;
}
.perm-items {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 4px; padding: 8px 12px;
}
.perm-item { font-size: 13px; }
.perm-code { font-size: 11px; color: var(--text-3); margin-left: 4px; }

/* ---------- 字典选项管理 ---------- */
.item-add {
  display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.item-list {
  max-height: 400px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 4px;
}
.item-list .table th {
  position: sticky; top: 0; background: var(--card-bg, #fff); z-index: 1;
}

/* ---------- 链接与错误提示 ---------- */
a.link { color: var(--primary); cursor: pointer; text-decoration: none; }
a.link:hover { text-decoration: underline; }
.err-msg {
  color: var(--danger); font-size: 12px; margin-top: 3px;
  word-break: break-all;
}
code {
  background: var(--bg); padding: 1px 5px; border-radius: 3px;
  font-size: 12px; font-family: Consolas, Monaco, monospace;
}

/* ============================================================
   移动端专项优化
   【为什么单独一节而不是零散加规则】
     工地上 90% 的操作发生在手机上（工长在楼顶、班组长在工地），
     戴手套、阳光直射、单手操作——这三个约束决定了交互必须不同：
       · 触控目标 ≥ 44px（戴手套点不准小的）
       · 关键操作放底部（拇指够得到）
       · 表格不横滚（横滚是手机上最难受的交互）
   这些规则散落在各处会互相覆盖，维护成本高。
   ============================================================ */

/* ---------- 全局触控优化 ---------- */
@media (max-width: 768px) {
  /* 去掉点击时的灰色高亮块（工地上看着像坏了） */
  * { -webkit-tap-highlight-color: transparent; }

  /* 触控目标放大到 44px：戴手套时 36px 经常点不中 */
  .btn, .btn-sm, .btn-xs { min-height: 40px; }
  .btn-xs { padding: 6px 12px; font-size: 13px; }
  /* 行内按钮在手机上独占一行更好点 */
  .tbl td.nowrap .btn-xs { margin-bottom: 4px; }

  /* 表单控件加大：手机上 14px 以下的输入框系统会主动放大页面 */
  .input, .select, textarea { font-size: 16px; min-height: 40px; }
  textarea { min-height: 80px; }

  /* 筛选项竖排，每个占满一行 */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-item { width: 100%; flex: none; }
  .filter-item label { display: block; margin-bottom: 4px; }
  .filter-actions { display: flex; gap: 8px; }
  .filter-actions .btn { flex: 1; }

  /* 弹窗从底部弹出，拇指可达；高度给足 92vh */
  .modal-mask { align-items: flex-end; }
  .modal { max-height: 92vh; display: flex; flex-direction: column; }
  .modal-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .modal-head, .modal-foot { flex-shrink: 0; }
  /* 弹窗按钮加大，底部并排等宽 */
  .modal-foot .btn { flex: 1; height: 44px; }

  /* 权限/授权类长列表：手机上一屏放不下，必须能滚 */
  .perm-list, .grant-list, .item-list { max-height: 55vh; }
  .perm-items { grid-template-columns: 1fr; }
}

/* ---------- 横屏时的补充 ---------- */
/* 手机横过来时空间变宽，表格可以少转一点卡片流 */
@media (max-width: 900px) and (orientation: landscape) {
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-row { grid-template-columns: repeat(4, 1fr); }
  .perm-items { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 平板 ---------- */
@media (min-width: 769px) and (max-width: 1180px) {
  .content { padding: 16px; }
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 表格卡片流的细节优化 ---------- */
@media (max-width: 768px) {
  .table-wrap.card-mode table.tbl tr { margin: 8px 6px; }
  /* 关键字段（第一格）加重，方便扫读 */
  .table-wrap.card-mode table.tbl td:first-child {
    font-weight: 600; font-size: 14px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light); margin-bottom: 4px;
  }
  .table-wrap.card-mode table.tbl td:first-child::before { display: none; }
  /* 金额与数量右对齐，扫一眼就知道数 */
  .table-wrap.card-mode table.tbl td.right,
  .table-wrap.card-mode table.tbl td.num { text-align: right; }
  /* 操作按钮独占一行、居中 */
  .table-wrap.card-mode table.tbl td[data-label="操作"] {
    justify-content: center; flex-wrap: wrap; gap: 4px;
    border-top: 1px solid var(--border-light); margin-top: 6px; padding-top: 10px;
  }
  .table-wrap.card-mode table.tbl td[data-label="操作"]::before { display: none; }
}

/* ---------- 安全区（iPhone 刘海屏） ---------- */
@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    .mobile-tabs { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
    .modal-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .toast-wrap { top: max(10px, env(safe-area-inset-top)); }
  }
}

/* ---------- 深色模式下的卡片 ---------- */
[data-theme="dark"] .table-wrap.card-mode table.tbl tr { background: var(--card-bg, #1e1e1e); }

/* ---------- 报表列设置条 ---------- */
.col-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--bg);
  font-size: 12px; color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 768px) {
  .col-bar { padding: 8px 10px; }
}
