/* ============================================================
   FLOW 响应式样式(分辨率自适应)
   移动端已合并进主端:一套页面按视口宽度自适应布局
   断点:≤767px 手机 | 768–1024px 平板(大部分结构已自适应)
   ============================================================ */

/* 联系人页:手机端标签切换行,桌面端默认隐藏(仅 ≤767px 媒体查询内显示;
   必须置于媒体查询之前,否则同优先级会覆盖手机端 display:flex) */
.m-contact-bar { display: none; }

/* ---------- 底部 Tab 导航(仅窄屏) ---------- */
.m-tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.m-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-3);
}
.m-tab:hover { text-decoration: none; color: var(--text-2); }
.m-tab svg { width: 22px; height: 22px; }
.m-tab.active { color: var(--primary); }

/* ---------- 移动端统计卡(按原型:仅 2 张,与我关联;默认隐藏,竖屏显示) ---------- */
.m-stats { display: none; }

/* ---------------- ≤767px 手机 ---------------- */
@media (max-width: 767px) {
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0)); }

  /* 概况页手机端:隐藏看板与指派给我区块(仅保留统计卡 + 状态事件 tab 区) */
  .m-hide-mobile { display: none !important; }

  /* 顶栏:压缩高度,隐藏搜索框与导航(移动端由底部 Tab 承载),品牌含文字无版本号 */
  .topbar-inner {
    height: 50px;
    padding: 0 12px;
    gap: 10px;
    overflow: hidden;
    /* 手机端两端对齐:品牌靠左,消息铃铛+用户菜单靠右,中间留白(桌面端保持原样) */
    justify-content: space-between;
  }
  .brand { gap: 8px; font-size: 15px; }
  .brand-mark { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }
  .brand-text { display: inline-flex; align-items: baseline; gap: 6px; }
  .brand-ver { display: none; }
  .topnav { display: none; }
  .searchbox { display: none; }
  .icon-btn { width: 32px; height: 32px; }
  .user-name { display: none; }
  .user-drop > summary .ico:last-child { display: none; }

  /* 页面容器 */
  .container { padding: 14px 12px; }
  .page-head { align-items: center; }
  .page-head h1 { font-size: 18px; }
  .page-head .sub { font-size: 12px; }
  .page-head .actions { gap: 6px; }

  /* 底部 Tab 显示 */
  .m-tabbar { display: flex; }

  /* 侧边菜单(设置/管理页):手机端隐藏,与「我的」界面菜单重复,入口由该界面承担 */
  .side-menu { display: none; }

  /* 概况统计:竖屏切换为移动端 2 卡(与我关联),隐藏桌面 4 卡 */
  .stat-cards { display: none; }
  .m-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .m-stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    display: block;
    color: var(--text);
  }
  .m-stat:hover { text-decoration: none; box-shadow: var(--shadow-lg); }
  .m-stat .l { font-size: 12px; color: var(--text-3); }
  .m-stat .v { font-size: 24px; font-weight: 800; margin-top: 2px; }
  .m-stat .h { font-size: 11px; color: var(--text-3); margin-top: 2px; }
  .m-stat.primary { background: var(--primary); border-color: var(--primary); }
  .m-stat.primary .l, .m-stat.primary .h { color: rgba(255,255,255,.85); }
  .m-stat.primary .v { color: #fff; }

  /* 筛选栏纵向堆叠 */
  .filters { gap: 10px; padding: 12px; }
  .filters .fgroup { width: 100%; }
  .filters .fgroup select,
  .filters .fgroup input[type="text"] { flex: 1; width: 100%; min-width: 0; }
  .filters .spacer { display: none; }
  .filters .fgroup:last-child { justify-content: flex-end; }

  /* 看板单列 */
  .kanban { grid-template-columns: 1fr; gap: 12px; }

  /* 概况行卡片:
     ov-row 改为窄屏紧凑展示 */
  .ov-row { padding: 12px; gap: 10px; }

  /* 表格卡片化(需 td 带 data-label) */
  .table-wrap { overflow: visible; background: transparent; border: none; border-radius: 0; box-shadow: none; }
  table.table, table.table tbody, table.table tr, table.table td { display: block; width: 100%; }
  table.table thead { display: none; }
  table.table tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px 12px;
    margin-bottom: 10px;
  }
  table.table tr:last-child { margin-bottom: 0; }
  table.table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px dashed var(--border);
    padding: 7px 2px;
    font-size: 13px;
  }
  table.table td:last-child { border-bottom: none; }
  table.table td.muted { display: block; border: none; }
  table.table td.nowrap { white-space: normal; }
  table.table td[data-label]::before {
    content: attr(data-label);
    color: var(--text-3);
    font-size: 12px;
    flex: none;
  }
  table.table td[data-label]::marker { content: none; }
  /* 操作列按钮排在一行 */
  table.table td form { display: inline-flex; }

  /* 弹窗:窄屏全屏式(底部滑出) */
  .modal-mask {
    align-items: flex-end;
    padding: 0;
  }
  .modal-mask .modal {
    width: 100%;
    max-width: 100%;
    max-height: 86vh;
    overflow-y: auto;
    border-radius: 14px 14px 0 0;
    animation: modal-up .22s ease;
  }
  @keyframes modal-up {
    from { transform: translateY(40px); opacity: .6; }
    to { transform: translateY(0); opacity: 1; }
  }

  /* 详情页侧栏与主栏间距 */
  .detail-layout { gap: 14px; }
  .side-panel .panel { margin-bottom: 14px; }
  .panel { padding: 14px; }

  /* 流程追加 / 留言 操作区 */
  .flow-actions .flex, .comment-input + .flex { flex-wrap: wrap; gap: 8px; }
  .flow-actions .fgroup { width: 100%; }

  /* 长表单底部操作区:窄屏换行堆叠 */
  .form > .flex.justify-between { flex-wrap: wrap; gap: 10px; }

  /* 待办清单:加大勾选触点,删除按钮常显(移动端无 hover) */
  .checklist li { padding: 10px 8px; gap: 10px; }
  .checklist input[type="checkbox"] { width: 18px; height: 18px; }
  .checklist li .act { visibility: visible; }

  /* 个人中心 */
  a.profile-user { padding: 14px 4px; margin: 0; }
  .profile-link { padding: 13px 4px; }

  /* 通知 / 消息列表 */
  .noti-row, .panal-row { padding: 12px; }

  /* 新建事件等长表单 */
  .form-row { gap: 0 14px; }
  .form-item { margin-bottom: 12px; }

  /* 弹窗正文与底部操作区贴边 */
  .modal .m-body { padding: 16px; }
  .modal .m-foot { padding: 12px 16px; }

  /* 联系人页(手机端):标签切换 + 添加按钮 + 搜索栏一行 */
  .page-head .actions { display: none; }                 /* 隐藏桌面「新增外部联系人」按钮 */
  .sec-head { display: none; }                            /* 隐藏内/外联系人旧标题(由标签行替代) */
  .m-contact-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin: 0 0 12px;
  }
  .m-contact-bar .seg { flex: none; }
  .m-contact-bar .tab-btn {
    display: inline-block; padding: 4px 12px; border-radius: 6px;
    color: var(--text-2); font-size: 13px;
  }
  .m-contact-bar .tab-btn.active { background: var(--card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
  .m-contact-bar .m-add-contact { flex: none; white-space: nowrap; }
  .m-bar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
  .m-search-toggle {
    width: 30px; height: 30px; padding: 0;
    border: 1px solid var(--border-2); border-radius: 8px;
    background: var(--card); color: var(--text-2); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .m-search-toggle .ico { width: 16px; height: 16px; }
  .m-search-toggle:hover { color: var(--primary); border-color: var(--primary); }
  .m-search-toggle.is-open { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
  /* 搜索栏:默认收起(精简界面),点击放大镜展开为一行;覆盖上方纵向堆叠规则 */
  .filters { display: none; }
  .filters.is-open { display: flex; flex-direction: row; align-items: center; gap: 8px; flex-wrap: nowrap; }
  .filters .fgroup { width: auto; margin: 0; }
  .filters .fgroup:first-child { flex: 1; min-width: 0; }
  .filters .fgroup input[type="text"] { width: 100%; min-width: 0; flex: 1; }
  .filters .fgroup:last-child { flex: none; justify-content: flex-end; gap: 6px; }
  /* 列表切换初始状态:默认显示内部联系人 */
  #tbl-internal { display: block; }
  #tbl-external { display: none; }

  /* 联系人卡片(手机端):简化为一行「姓名 + 部门/单位」,点击弹详细卡片 */
  #tbl-internal tr, #tbl-external tr {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; cursor: pointer;
  }
  #tbl-internal tr:active, #tbl-external tr:active { background: var(--gray-bg); }
  /* 隐藏除姓名(第1列)与部门/单位(第3列)外的字段 */
  #tbl-internal td:nth-child(2), #tbl-internal td:nth-child(n+4),
  #tbl-external td:nth-child(2), #tbl-external td:nth-child(n+4) { display: none; }
  /* 姓名列:不加标签,加粗显示 */
  #tbl-internal td:first-child, #tbl-external td:first-child {
    display: block; flex: none; border: none; padding: 0;
    font-weight: 600; font-size: 14px; color: var(--text);
  }
  #tbl-internal td:first-child::before, #tbl-external td:first-child::before { content: none; }
  /* 部门/单位列:显示为次要信息,前面加小圆点分隔 */
  #tbl-internal td:nth-child(3), #tbl-external td:nth-child(3) {
    display: block; flex: 1; border: none; padding: 0;
    font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #tbl-internal td:nth-child(3)::before, #tbl-external td:nth-child(3)::before {
    content: '·'; margin-right: 6px; font-weight: 700;
  }
  /* 空态行(无匹配数据):保持整行文字展示,不可点击 */
  #tbl-internal tr:has(td[colspan]), #tbl-external tr:has(td[colspan]) { display: block; cursor: default; }
  #tbl-internal tr:has(td[colspan]) td, #tbl-external tr:has(td[colspan]) td {
    display: block; border: none; padding: 8px 2px; font-weight: 400; font-size: 13px; color: var(--text-3);
  }
  #tbl-internal tr:has(td[colspan]) td::before, #tbl-external tr:has(td[colspan]) td::before { content: none; }

  /* 登录页 */
  .login-wrap { padding: 24px 16px; }
  .login-box { width: 100%; max-width: 380px; margin: 0 auto; }
}

/* ---------------- 768–1100px 平板微调 ---------------- */
@media (min-width: 768px) and (max-width: 1100px) {
  .container { padding: 20px 16px; }
  .searchbox { width: 180px; }
}

/* ---------------- 个人中心(profile)通用样式 ---------------- */
.profile-card { padding: 16px 18px; }
.profile-user { display: flex; align-items: center; gap: 14px; }
.profile-user .avatar.lg { width: 52px; height: 52px; font-size: 18px; flex: none; }
.pu-name { font-size: 17px; font-weight: 700; }
.pu-meta { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }

/* 用户信息卡整体可点击(头像/姓名 → 个人信息设置) */
a.profile-user {
  text-decoration: none;
  color: var(--text);
  border-radius: 12px;
  transition: background .15s;
  padding: 4px;
  margin: -4px;
}
a.profile-user:hover { background: var(--gray-bg); }
a.profile-user:hover .pu-name { color: var(--primary); }
a.profile-user .pl-arrow { margin-left: auto; color: var(--text-3); flex: none; }

.profile-panel { padding: 4px 18px; }
.profile-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.profile-link:last-child { border-bottom: none; }
.profile-link:hover { text-decoration: none; color: var(--primary); }
.pl-ico {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--gray-bg); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.profile-link:hover .pl-ico { background: var(--primary-light); color: var(--primary); }
.pl-text { flex: 1; font-size: 14px; }
.pl-arrow { color: var(--text-3); }

.w-100 { width: 100%; }

/* 联系人弹窗:类型切换 seg(全端通用) */
.seg-full { display: flex; }
.seg-full .tab-btn { flex: 1; text-align: center; padding: 6px 12px; border-radius: 6px; color: var(--text-2); font-size: 13px; }
.seg-full .tab-btn.active { background: var(--card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
#contact-modal-tabs { margin-bottom: 10px; }

/* 联系人详情卡片弹窗(手机端点击列表弹出) */
.cd-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.cd-row:last-child { border-bottom: none; }
.cd-label { flex: none; width: 66px; color: var(--text-3); font-size: 12.5px; }
.cd-value { flex: 1; min-width: 0; color: var(--text); word-break: break-all; }
.cd-value .badge { vertical-align: middle; }
.cd-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.cd-actions form { display: inline-flex; }

/* ---------------- 概况页:状态事件 tab(全部 / 处理中 / 待处理) ----------------
   桌面端:tab 条隐藏,两个列表并列显示;手机端(≤767px):tab 切换合并,
   默认显示「全部」(桌面端已有看板承载全部事件,故 .m-all-panel 桌面端隐藏)。
   新状态后续在同排添加 tab + 面板即可。 */
.m-stab-row { display: none; }
.m-stab-panel { display: block; }
/* 概况页「全部」面板:仅手机端显示,随 tab 显隐 */
.m-all-panel { display: none; }
/* 事件页:状态 Tab + 懒加载卡片面板,桌面端默认隐藏(手机端显示,替代表格) */
.m-item-tabs { display: none; }
.m-item-panels { display: none; }
@media (max-width: 767px) {
  .m-stab-row {
    display: flex; gap: 8px;
    overflow-x: auto; scrollbar-width: none;
    margin: 2px 0 14px;
  }
  .m-stab-row::-webkit-scrollbar { display: none; }
  .m-stab {
    flex: none; height: 30px; padding: 0 14px; border-radius: 15px;
    border: 1px solid var(--border-2); background: var(--card);
    font-size: 12.5px; color: var(--text-2); font-family: inherit;
    display: inline-flex; align-items: center; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
  }
  .m-stab:active { background: var(--gray-bg); }
  .m-stab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
  .m-stab-panel { display: none; }
  .m-stab-panel.show { display: block; }
  .m-all-panel.show { display: block; }

  /* 事件页(手机端):状态 Tab(全部/处理中/待处理/已完成)+ 懒加载卡片列表,替代表格 */
  .m-item-tabs {
    display: flex; gap: 8px;
    overflow-x: auto; scrollbar-width: none;
    margin: 2px 0 14px;
  }
  .m-item-tabs::-webkit-scrollbar { display: none; }
  .m-item-tabs .m-stab { flex: none; height: 30px; padding: 0 14px; border-radius: 15px; border: 1px solid var(--border-2); background: var(--card); font-size: 12.5px; color: var(--text-2); font-family: inherit; display: inline-flex; align-items: center; cursor: pointer; }
  .m-item-tabs .m-stab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
  .m-item-panels { display: block; }
  /* 仅事件页:隐藏原表格(只保留简洁卡片;!important 防止任何级联/覆盖规则重新显示) */
  .items-table { display: none !important; }
}