@layer components {
/* ===== 手机端 baseline 微调（小尺寸默认）===== */
@media (max-width: 959px) {
  html, body { height: 100%; overflow: hidden; }
  .layout { height: 100dvh; min-height: 100dvh; overflow: hidden; }
  .main {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
  }
  body[data-mp="home"] .mini-topbar,
  body:not([data-mp]) .mini-topbar,
  body[data-mp="orders"] .mini-topbar { display: none !important; }
  body[data-mp="home"] .workbench {
    display: grid !important;
    flex: 1 1 auto;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 14px 12px calc(76px + env(safe-area-inset-bottom, 0px));
    min-height: 0;
    height: auto;
    align-content: start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body[data-mp="home"] .welcome-panel { align-items: flex-start; }
  body[data-mp="home"] .welcome-panel p { flex: none; min-height: 0; white-space: normal; }
  body[data-mp="home"] .content {
    display: none !important;
    flex: 0 0 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
  }
  body[data-mp="home"] .mobile-orders-chrome,
  body[data-mp="home"] .scope-bar { display: none !important; }
  body[data-mp="orders"] .workbench { display: none !important; }
  body[data-mp="orders"] .mobile-orders-chrome { display: block; flex: 0 0 auto; }
  body[data-mp="orders"] .mobile-status-bar {
    display: flex !important;
    flex-direction: column;
    overflow: visible;
    padding: 0;
  }
  body[data-mp="orders"] .m-chip-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }
  body[data-mp="orders"] .content {
    display: block !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px calc(72px + env(safe-area-inset-bottom, 0px));
  }
  body[data-mp="orders"] .view-head h2 { display: none; }
  body[data-mp="orders"] .view-hint { display: none; }
  body[data-mp="tools"] .mini-topbar,
  body[data-mp="me"] .mini-topbar { display: none; }

  body[data-mp="tools"] .workbench,
  body[data-mp="tools"] .content,
  body[data-mp="tools"] .mobile-orders-chrome,
  body[data-mp="tools"] #mobile-page-me { display: none !important; }
  body[data-mp="tools"] #mobile-page-tools {
    display: flex !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  body[data-mp="me"] .workbench,
  body[data-mp="me"] .content,
  body[data-mp="me"] .mobile-orders-chrome,
  body[data-mp="me"] #mobile-page-tools { display: none !important; }
  body[data-mp="me"] #mobile-page-me {
    display: flex !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 720px) {
  body { font-size: 13.5px; }
  .mini-topbar { height: 52px; padding: 0 14px; gap: 10px; }
  .mini-actions { gap: 6px; }
  .mini-actions .btn-text { display: none; }
  .mini-actions .btn-sm { padding: 7px 10px; }

  .content { padding: 14px 12px 90px; }
  .workbench {
    margin: 12px 12px 0; gap: 10px;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
  .welcome-panel { padding: 14px 16px; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
  .welcome-text { flex-direction: column; align-items: flex-start; gap: 2px; }
  .welcome-panel h2 { font-size: 16px; }
  .welcome-panel p { font-size: 12px; white-space: normal; }
  .welcome-badge { font-size: 11.5px; padding: 4px 10px; }
  .reminder-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .reminder-card { padding: 8px 10px 8px 12px; border-radius: 8px; gap: 8px; }
  .reminder-card strong { font-size: 17px; }
  .reminder-icon { width: 26px; height: 26px; border-radius: 8px; }
  .reminder-icon svg { width: 13px; height: 13px; }
  .wb-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .wb-kpi-row-sm { grid-template-columns: repeat(3, 1fr); }
  .wb-kpi-num { font-size: 20px; }
  .wb-community-list { grid-template-columns: 1fr; }
  .wb-urgent-item { grid-template-columns: auto 1fr; }
  .wb-urgent-phone { display: none; }
  .oc-main { flex-direction: column; }
  .oc-action-col { width: 100%; flex-direction: row; justify-content: flex-end; }
  .oc-action-col .btn-primary { flex: 1; min-height: 42px; border-radius: 10px; font-size: 14px; }
  .oc-sec-btns .btn { min-height: 38px; }
  .view { padding: 12px 14px 16px; border-radius: 8px; }
  .user-form-grid { grid-template-columns: 1fr 1fr; }
  .users-branch-head { align-items: flex-start; }
  /* 全局口径条：手机上紧凑——标签+按钮同一行（标签固定窄、按钮占满剩余），
     隐藏自定义日期选择器（快捷按钮已覆盖常用，腾出竖向空间），隐藏口径文字提示 */
  .scope-bar { gap: 8px; padding-top: 7px; padding-bottom: 7px; }
  .scope-group { width: 100%; flex-direction: row; align-items: center; gap: 8px; }
  .scope-label { flex: 0 0 auto; font-size: 11.5px; min-width: 40px; }
  .scope-group .date-quick { flex: 1; min-width: 0; justify-content: space-between; }
  .scope-group .dq-seg { flex: 1; text-align: center; padding: 7px 2px; font-size: 12px; }
  .scope-group .date-custom { display: none; }   /* 手机端隐藏自定义日期选择器 */
  .scope-hint { display: none; }                  /* 手机端隐藏「当前口径」文字 */
  /* 口径弹层：手机端全宽 */
  .scope-pop { left: 12px; right: 12px; top: 60px; max-width: none; }

  /* 底部 tabbar：手机端显示，4 个快捷入口 */
  .bottom-tabbar {
    display: flex; justify-content: space-around;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    background: var(--clr-card); border-top: 1px solid var(--clr-border-light);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bt-item {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: transparent; border: none; color: var(--clr-muted-fg);
    font-size: 11px; padding: 4px 2px; border-radius: 8px;
    cursor: pointer; transition: color .14s, background .14s;
  }
  .bt-item:hover { color: var(--clr-fg); background: var(--clr-bg); }
  .bt-item.active { color: var(--clr-primary); }
  .bt-item svg { width: 20px; height: 20px; }

  /* 卡片单列、占满宽度，手指友好 */
  .grid-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .gm-card { padding: 10px 12px; border-radius: 8px; }
  .gm-card:active { transform: scale(.98); }
  .gm-card .gm-count b { font-size: 22px; }
  .gm-card .gm-name { font-size: 14px; }

  .view-head { gap: 10px; margin-bottom: 14px; }
  .view-head h2 { font-size: 16px; }
  .view-head .input { margin-left: 0; width: 100%; min-width: 0; }
  .view-hint { display: none; }

  /* 工单卡片：手机端微调 */
  .order-card { padding: 10px 12px 8px; }
  .oc-body { flex-direction: column; align-items: stretch; gap: 8px; }
  .oc-actions { justify-content: flex-end; }
  .oc-actions .btn[data-act="book"] { flex: 1; justify-content: center; min-height: 44px; height: 44px; border-radius: 10px; font-size: 14px; }
  .oc-actions .btn { min-height: 40px; }
  .oc-responsibility { grid-template-columns: 1fr; }
  .order-view-switch { width: 100%; margin-left: 0; padding: 7px 0 0; border-left: 0; border-top: 1px solid var(--clr-border); }
  .community-group-head { align-items: flex-start; flex-direction: column; gap: 3px; }
  .oc-footer span { max-width: 180px; }
  .modal-order-summary .s-dispatch { grid-template-columns: 1fr; gap: 6px; }
  .modal-tool-row { flex-wrap: wrap; }
  .modal-tool-row .tool-btn { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); }

  /* 弹窗底部置底，像原生底部抽屉：圆角顶部 + 上滑动画 + 顶部把手 */
  .modal { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; align-self: flex-end; animation: sheet-up .28s cubic-bezier(.32,.72,0,1); }
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal-mask:not([hidden]) { display: flex; }
  .modal > .modal-head { position: relative; padding-top: 20px; }
  .modal > .modal-head::before {
    content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 5px; border-radius: 999px; background: var(--clr-border);
  }
  /* 分段控件：手机端 2×2 网格，大号点按目标 */
  .action-seg-group { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .action-seg { min-height: 56px; border-radius: 12px; flex-direction: row; justify-content: flex-start; padding: 10px 14px; gap: 10px; }
  .action-seg-label { text-align: left; font-size: 13px; }
  .action-seg-ic { width: 32px; height: 32px; }
  .action-seg-ic svg { width: 17px; height: 17px; }
  /* 大号点按目标 */
  .modal-foot .btn, .modal > .modal-foot .btn { min-height: 48px; border-radius: 12px; font-size: 15px; }
  .option { min-height: 56px; border-radius: 12px; }
  .halfday-group .seg { min-height: 48px; }
  .tool-btn { min-height: 60px; }
  .issue-kind-chip { min-height: 44px; }
  /* 输入框更大点按区 */
  .modal-body .input { min-height: 44px; font-size: 15px; }
  .modal-body textarea.input { min-height: 80px; }
  /* 关闭按钮更大 */
  .modal-close { min-width: 36px; min-height: 36px; font-size: 20px; display: inline-flex; align-items: center; justify-content: center; }

  /* 网格配置：表单纵向、表格横向滚动 */
  .modal.modal-lg { width: 100%; max-height: 92vh; }
  .cfg-form-row, .cfg-form-row.cfg-3 { display: flex; flex-direction: column; }
  .cfg-form-row.cfg-actions { flex-direction: row; }
  .cfg-table-wrap { max-height: 55vh; }
  .cfg-table .cfg-team { max-width: 160px; word-break: break-all; }
  .cfg-table thead th:nth-child(4), .cfg-table tbody td:nth-child(4) { display: none; }

  /* 统计：图表单列堆叠 */
  .modal.modal-xl { width: 100%; max-height: 94vh; }
  .imap-layout { grid-template-columns: 1fr; min-height: 0; }
  .imap-map-wrap, .imap-canvas { min-height: 260px; }
  .imap-side { max-height: 40vh; }
  .imap-stats { margin-left: 0; width: 100%; }
  .wr-num-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wr-num-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .modal.modal-wr {
    width: 100%; max-width: 100%;
    max-height: 100vh; max-height: 100dvh;
    border-radius: 12px 12px 0 0;
  }
  .wr-metric .input { font-size: 20px; }
  .wr-card-head-row { flex-wrap: wrap; }
  .wr-body { padding-bottom: 24px; }
  .stat-kpis { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .kpi { padding: 11px 12px; }
  .kpi .kpi-value { font-size: 22px; }
  .stat-charts { grid-template-columns: 1fr; }
  .stat-canvas-wrap { height: 220px; }
  .stat-canvas-wrap.stat-canvas-tall { height: 300px; }

  /* 标记竣工回溯列表：手机端两行布局（工单号+账号 / 操作人+时间）*/
  .complete-rec {
    grid-template-columns: 1fr auto;
    grid-template-areas: "form time" "src op";
    row-gap: 3px;
  }
  .complete-rec .cr-form { grid-area: form; }
  .complete-rec .cr-time { grid-area: time; }
  .complete-rec .cr-src { grid-area: src; }
  .complete-rec .cr-op { grid-area: op; text-align: right; }

  /* 日期筛选条纵向堆叠 */
  .date-filter { gap: 10px; }
  .date-quick { width: 100%; justify-content: space-between; }
  .dq-seg { flex: 1; text-align: center; padding: 8px 6px; }
  .date-custom { width: 100%; }
  .input-date { flex: 1; width: auto; }
  .date-filter-count { margin-left: 0; }
}

@media (max-width: 380px) {
  .grid-cards { grid-template-columns: 1fr; }
  .reminder-grid { grid-template-columns: 1fr; }
  .user-form-grid { grid-template-columns: 1fr; }
}

/* Excel 约单工具 */
.excel-appoint-body { display: flex; flex-direction: column; gap: 18px; }
.excel-section { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2, var(--clr-muted)); }
.excel-sec-title { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.excel-btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.excel-mine-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 8px; }
.excel-mine-filters .jkq-field { min-width: 0; }
.excel-mine-filters .input { min-width: 0; width: 140px; }
.excel-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--clr-muted-fg); padding-bottom: 6px; }
.excel-import-result { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.excel-status-ok { color: var(--clr-success) !important; }
.excel-status-err { color: var(--clr-destructive) !important; }
} /* end @layer components */
