/* ==========================================================================
   凤凰庄大数据 · 移动端设计层（mobile.css）
   --------------------------------------------------------------------------
   定位：app.css 之后的补充层，只在 ≤820px 生效，桌面端零影响。
   设计基线：390 × 844（iPhone 13/14），向上适配 430（Pro Max）、
             向下兼容 360（主流安卓），横屏走高度断点。
   设计原则：
     1. 一屏之内必须先看到数字，再看到装饰 —— 压缩所有非数据区高度
     2. 所有可点元素 ≥ 44 × 44（iOS HIG）/ 48 × 48（Material）
     3. 双列网格承载指标，长列表用折叠 + 快捷跳转消化
     4. 依赖 :active 反馈，不依赖 hover
     5. 安全区（刘海 / 手势条）全部用 env() 兜底
   ========================================================================== */

/* --------------------------------------------------------------------------
   桌面端基线：移动端专属元素一律不出现
   （.mobile-header 在 app.css 里只在 ≤768px 有样式，桌面端会作为裸 div
     挤进 .app 的 flex 行，占一条 96px 宽的竖条 —— 这里统一收掉）
   -------------------------------------------------------------------------- */
.mobile-header,
.m-tabbar,
.m-chips { display: none; }

/* 未登录时不显示 AI 悬浮球（它原本浮在登录表单上方） */
.app:not(.show) ~ .ai-fab { display: none; }

/* 页头动作容器：桌面端保持一行（新增的包裹层，不能破坏原布局） */
.page-header .ph-actions { display: flex; align-items: center; gap: 12px; }

@media (max-width: 820px), (orientation: landscape) and (max-height: 480px) {

  /* ---------- 0. 设计变量（移动端专用） ---------------------------------- */
  :root {
    --m-appbar: 54px;         /* 顶部应用栏 */
    --m-filter: 46px;         /* 期间筛选条 */
    --m-tabbar: 62px;         /* 底部标签栏（含 4px 内侧留白，避免手势条压字） */
    --m-gutter: 14px;         /* 页面左右留白 */
    --m-gap: 10px;            /* 卡片间距 */
    --m-radius: 12px;
    --m-safe-t: env(safe-area-inset-top, 0px);
    --m-safe-b: env(safe-area-inset-bottom, 0px);
  }

  /* ---------- 1. 框架：修掉侧栏在移动端占据文档流的历史问题 ------------- */
  /* app.css 末尾 .sidebar{position:relative} 覆盖了移动端 fixed，导致
     侧栏以 280px 宽、约 460px 高占据页面顶部，首屏全是空白。这里重新压回 fixed。 */
  .app .sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    bottom: 0;
    width: min(84vw, 306px);
    height: 100dvh;
    z-index: 1001;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    transition: left .28s cubic-bezier(.32, .72, 0, 1);
  }
  .app .sidebar.open {
    left: 0;
    box-shadow: 8px 0 32px rgba(0, 0, 0, .38);
  }
  /* 侧栏遮罩：app.css 只在 ≤768px 定义了 display:none，768~820 与横屏手机
     会退化成裸 div（全屏黑幕 + 吞掉所有点击），这里补齐。 */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1000;
  }
  .sidebar-overlay.show { display: block; }

  /* 侧栏星空/极光在移动端关掉：省电、滚动更跟手 */
  .sidebar .sb-stars,
  .sidebar .sb-aurora { display: none !important; }

  .app.show {
    min-height: 100dvh;
    flex-direction: column;
  }
  .main {
    width: 100%;
    padding: 0 var(--m-gutter);
    padding-bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 24px);
    overflow: visible;              /* 交给 body 滚动，避免与 sticky 打架 */
    -webkit-overflow-scrolling: touch;
  }

  /* ---------- 2. 顶部应用栏 --------------------------------------------- */
  .mobile-header {
    display: flex !important;      /* app.js 会内联写 display:flex/none，这里统一接管 */
    position: sticky;
    top: 0;
    z-index: 60;
    height: calc(var(--m-appbar) + var(--m-safe-t));
    padding: var(--m-safe-t) 6px 0 6px;
    align-items: center;
    gap: 6px;
    background: color-mix(in srgb, var(--bg2) 88%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
  }
  .mobile-header .mobile-title {
    flex: 1 1 auto;
    min-width: 0;
  }
  .mobile-header .menu-btn,
  .mobile-header .mobile-ai-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    padding: 0;
  }
  .mobile-header .menu-btn:active,
  .mobile-header .mobile-ai-btn:active { background: rgba(var(--brand-rgb), .14); }
  .mobile-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .5px;
    text-align: left;
    padding-left: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ---------- 3. 期间筛选条：两行压成一行 --------------------------------- */
  .date-bar {
    position: sticky;
    top: calc(var(--m-appbar) + var(--m-safe-t));
    z-index: 55;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    height: var(--m-filter);
    padding: 0;
    margin: 0 calc(-1 * var(--m-gutter)) 12px;
    padding-left: var(--m-gutter);
    padding-right: var(--m-gutter);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .date-bar-left {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .date-bar select {
    width: auto;
    max-width: 128px;
    height: 34px;
    padding: 0 28px 0 12px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 9px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text3) 50%), linear-gradient(135deg, var(--text3) 50%, transparent 50%);
    background-position: calc(100% - 15px) 14px, calc(100% - 11px) 14px;
    background-size: 4px 4px, 4px 4px;
    background-repeat: no-repeat;
    appearance: none;
    -webkit-appearance: none;
  }
  .date-bar-right {
    text-align: right;
    min-width: 0;
    overflow: hidden;
  }
  .date-bar-right #date-label {
    font-size: 11px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
  }
  /* 自定义区间：展开成第二行，仍然紧凑 */
  .date-range {
    flex-direction: row !important;
    gap: 6px;
    align-items: center;
  }
  .date-range input[type="date"] {
    width: 122px;
    height: 34px;
    font-size: 12px;
    padding: 0 6px;
    border-radius: 9px;
  }

  /* ---------- 4. 页面标题区 ------------------------------------------------
     标题已在应用栏显示（见上），这里只放真正需要的动作。 */
  .page-header {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    min-height: 36px;
  }
  .page-header h1 {
    display: none !important;       /* 与应用栏标题重复，移动端隐藏 */
  }

  /* 经营总览的「同步」整块在移动端下线：一键同步 / 中止 / 进度面板 /
     实时数据圆点 / 数据截至条全隐藏。同步与数据新鲜度只在桌面客户端体现。
     注意：DOM 保留不删——app.js 的 ovSyncStart() 仍按 id 取元素，
     删节点会让 onclick 直接抛 TypeError。故一律用 display:none 隐藏，
     且必须 !important（进度面板的 display 由 JS 写成内联样式）。 */
  #sec-overview .page-header,
  #ov-sync-btn,
  #ov-sync-cancel,
  #ov-sync-panel,
  .ov-asof {
    display: none !important;
  }
  /* 头部与截至条去掉后，首个分组会紧贴筛选条，补一点呼吸空间 */
  #sec-overview { padding-top: 8px; }

  /* ---------- 5. KPI：双列网格 + 数值自适应 ------------------------------ */
  .ov-group { margin-bottom: 14px; }
  .ov-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    margin: 0 0 8px;
    padding: 0 0 0 9px;
    height: 22px;
    border-left: 3px solid var(--brand);
    line-height: 1;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: var(--m-gap) !important;
    min-height: 0 !important;
  }
  .kpi-card {
    padding: 11px 12px 10px;
    border-radius: var(--m-radius);
    min-height: 74px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: none;
  }
  .kpi-card:active { background: var(--bg3); }
  .kpi-label {
    font-size: 11.5px;
    margin-bottom: 5px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .kpi-value {
    font-size: 19px;
    line-height: 1.15;
    letter-spacing: -.2px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;          /* 单行显示，配合 mobile.js 自动降字号 */
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .kpi-sub {
    font-size: 10.5px;
    margin-top: 4px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .kpi-warn { top: 8px; right: 8px; width: 16px; height: 16px; font-size: 11px; }

  /* 环形卡（周转类）：缩小环，让一屏能放下两行 */
  .kpi-card-ring {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    text-align: left;
    min-height: 74px;
    padding: 10px 12px;
  }
  .kpi-card-ring .kpi-label {
    margin-bottom: 0;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
  }
  .kpi-ring {
    width: 52px !important;
    height: 52px !important;
    margin: 0 !important;
    flex: 0 0 auto;
    order: 2;
  }
  .kpi-ring-inner {
    width: 38px;
    height: 38px;
    font-size: 12px;
  }
  .kpi-card-ring .kpi-sub { display: none; }

  /* 大屏手机 / 竖向平板：三列更经济 */
  @media (min-width: 680px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  }

  /* ---------- 6. 图表卡 -------------------------------------------------- */
  .ov-charts {
    grid-template-columns: 1fr !important;
    gap: var(--m-gap);
    margin-top: 4px;
  }
  .chart-card {
    min-height: 0;
    padding: 12px;
    border-radius: var(--m-radius);
    margin-bottom: 0;
  }
  .chart-card h3 {
    font-size: 12.5px;
    margin-bottom: 10px;
    gap: 7px;
  }
  .chart-card h3::before { width: 3px; height: 13px; }
  .chart-card canvas { max-height: 240px; }

  /* ---------- 7. 分组快捷跳转（由 mobile.js 生成） ------------------------ */
  .m-chips {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 2px 0 10px;
    margin: 0 calc(-1 * var(--m-gutter));
    padding-left: var(--m-gutter);
    padding-right: var(--m-gutter);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .m-chips::-webkit-scrollbar { display: none; }
  .m-chips button {
    flex: 0 0 auto;
    height: 32px;
    padding: 0 13px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--text2);
    font-size: 12px;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    transition: background .18s, color .18s, border-color .18s;
  }
  .m-chips button.on {
    background: rgba(var(--brand-rgb), .16);
    border-color: rgba(var(--brand-rgb), .55);
    color: var(--brand-bright, #22d3ee);
    font-weight: 600;
  }
  .m-chips button:active { transform: scale(.96); }

  /* 分组折叠态 */
  .ov-group.is-collapsed .kpi-grid { display: none; }
  .ov-group.is-collapsed .ov-group-title::after {
    content: '已收起';
    font-size: 10px;
    font-weight: 400;
    color: var(--text3);
    letter-spacing: 0;
    margin-left: 2px;
  }
  .ov-group.is-collapsed { margin-bottom: 10px; }

  /* ---------- 8. 底部标签栏 ---------------------------------------------- */
  .m-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    height: calc(var(--m-tabbar) + var(--m-safe-b));
    padding-bottom: calc(var(--m-safe-b) + 4px);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--bg2) 92%, transparent);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .22);
  }
  .m-tabbar[hidden] { display: none; }
  .m-tabbar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: 0;
    color: var(--text3);
    font-size: 10px;
    font-family: inherit;
    letter-spacing: .2px;
    cursor: pointer;
    padding: 0;
    position: relative;
  }
  .m-tabbar button svg { width: 21px; height: 21px; }
  .m-tabbar button.on { color: var(--brand); }
  .m-tabbar button.on::before {
    content: '';
    position: absolute;
    top: 6px;
    width: 26px;
    height: 3px;
    border-radius: 2px;
    background: var(--brand);
    box-shadow: 0 0 10px rgba(var(--brand-rgb), .8);
  }
  .m-tabbar button:active { background: rgba(var(--brand-rgb), .10); }
  /* 打开抽屉或切到内嵌页时，底部栏让位 */
  body.m-tabbar-off .m-tabbar { display: none; }
  body.m-tabbar-off .main { padding-bottom: 24px; }

  /* ---------- 8b. AI 助手：功能尚未成熟，移动端整体下线 -----------------
     （悬浮球 + 面板 + 应用栏右侧入口一起收掉，避免只关一半留死链） */
  .ai-fab,
  .ai-panel,
  .mobile-header .mobile-ai-btn { display: none !important; }

  /* ---------- 9. 抽屉内部：可点区域与关闭按钮 ---------------------------- */
  .sidebar .sidebar-header {
    height: calc(var(--m-appbar) + var(--m-safe-t));
    padding: var(--m-safe-t) 12px 0 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  .sidebar nav a,
  .sidebar nav .nav-group-title {
    min-height: 44px;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    display: flex;
    align-items: center;
    font-size: 13.5px;
  }
  .nav-group-items a { min-height: 40px; }
  .sidebar-close {
    display: flex !important;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--text2);
    font-size: 15px;
    line-height: 1;
    padding: 0;
  }
  .sidebar-close:active { background: var(--bg3); }
  .sidebar .nav-search { padding: 8px 12px 6px; }
  .sidebar .nav-search input { height: 38px; font-size: 13px; }
  .sidebar .sb-toggle { display: none; }   /* 移动端不需要收起侧栏 */

  /* ---------- 10. 触摸友好：去掉 hover 依赖，统一按压反馈 ----------------- */
  @media (hover: none) {
    .kpi-card:hover,
    .chart-card:hover,
    .btn:hover { transform: none !important; box-shadow: inherit; }
    .sidebar nav a:hover { background: transparent; }
  }
  .btn { min-height: 38px; }
  .btn-primary:active { filter: brightness(.92); }

  /* ---------- 13. iOS 毛玻璃语言（液态玻璃 / Liquid Glass） ---------------
     原则：
       · 只有「固定悬浮的 chrome」用真 backdrop-filter（数量可控、性能安全）
       · 卡片用「半透明渐变 + 1px 高光描边 + 大半径柔影」伪造玻璃，
         因为它背后只有大面积的柔和环境光，加 blur 肉眼无收益但很贵
       · 环境光必须存在，否则玻璃是死的 —— body::before 铺三团柔光
     ---------------------------------------------------------------------- */
  :root {
    --g-surface: linear-gradient(168deg, rgba(255, 255, 255, .095) 0%, rgba(255, 255, 255, .042) 100%);
    --g-line: rgba(255, 255, 255, .11);
    --g-line-strong: rgba(255, 255, 255, .20);
    --g-inset: inset 0 1px 0 rgba(255, 255, 255, .14);
    --g-shadow: 0 10px 28px -18px rgba(0, 0, 0, .85), 0 2px 6px -3px rgba(0, 0, 0, .35);
    --g-blur: saturate(180%) blur(26px);
    --g-radius: 16px;
  }
  [data-theme="light"] {
    --g-surface: linear-gradient(168deg, rgba(255, 255, 255, .82) 0%, rgba(255, 255, 255, .58) 100%);
    --g-line: rgba(15, 23, 42, .10);
    --g-line-strong: rgba(15, 23, 42, .16);
    --g-inset: inset 0 1px 0 rgba(255, 255, 255, .95);
    --g-shadow: 0 10px 26px -16px rgba(15, 23, 42, .42), 0 2px 6px -4px rgba(15, 23, 42, .20);
  }
  [data-theme="emerald"],
  [data-theme="violet"] {
    --g-line: rgba(255, 255, 255, .13);
    --g-line-strong: rgba(255, 255, 255, .22);
  }

  /* 环境光：玻璃背后的柔光，固定在视口，不随滚动重绘 */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(52% 38% at 6% -8%, rgba(var(--brand-rgb), .62) 0%, rgba(var(--brand-rgb), .26) 34%, transparent 64%),
      radial-gradient(42% 30% at 98% 2%, rgba(34, 211, 238, .40) 0%, rgba(34, 211, 238, .14) 36%, transparent 66%),
      radial-gradient(64% 40% at 50% 106%, rgba(var(--brand-rgb), .46) 0%, rgba(var(--brand-rgb), .16) 38%, transparent 68%);
  }
  [data-theme="light"] body::before {
    background:
      radial-gradient(58% 42% at 6% -8%, rgba(var(--brand-rgb), .26) 0%, transparent 66%),
      radial-gradient(46% 34% at 98% 2%, rgba(var(--brand-rgb), .16) 0%, transparent 70%),
      radial-gradient(70% 46% at 50% 106%, rgba(var(--brand-rgb), .20) 0%, transparent 72%);
  }

  /* 颗粒层：玻璃后面得有高频细节，模糊才看得出来 */
  body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .14;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='0.42'/></svg>");
    background-size: 160px 160px;
  }
  [data-theme="light"] body::after { opacity: .07; }

  /* 让环境光透上来 */
  .app,
  .main { background: transparent; }

  /* ---- 应用栏 ---- */
  .mobile-header {
    background: color-mix(in srgb, var(--bg2) 52%, transparent);
    backdrop-filter: saturate(180%) blur(34px);
    -webkit-backdrop-filter: var(--g-blur);
    border-bottom: 1px solid var(--g-line);
    box-shadow: none;
  }
  .mobile-header .menu-btn,
  .mobile-header .mobile-ai-btn {
    border-radius: 12px;
    color: var(--text);
    transition: transform .18s cubic-bezier(.32, .72, 0, 1), background .18s;
  }
  .mobile-header .menu-btn:active,
  .mobile-header .mobile-ai-btn:active {
    background: rgba(255, 255, 255, .10);
    transform: scale(.92);
  }
  /* 标题与桌面侧栏 logo「凤凰庄大数据」保持同一套：字重/字距/流光/辉光 */
  .mobile-title {
    font-weight: 700;
    letter-spacing: 1px;
    font-size: 15px;
    filter: drop-shadow(0 0 7px rgba(var(--brand-rgb), .42));
  }

  /* ---- 期间筛选条 ---- */
  .date-bar {
    background: color-mix(in srgb, var(--bg) 52%, transparent);
    backdrop-filter: saturate(170%) blur(24px);
    -webkit-backdrop-filter: saturate(160%) blur(18px);
    border-bottom: 1px solid var(--g-line);
  }
  .date-bar select {
    height: 32px;
    background: var(--g-surface);
    border: 1px solid var(--g-line);
    box-shadow: var(--g-inset);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-weight: 500;
  }
  .date-range input[type="date"] {
    background: var(--g-surface);
    border: 1px solid var(--g-line);
    box-shadow: var(--g-inset);
    border-radius: 10px;
  }

  /* ---- 主操作按钮：玻璃胶囊 ---- */
  .page-header .ph-sync {
    height: 34px;
    border-radius: 999px;
    padding: 0 15px;
    font-weight: 600;
    font-size: 12.5px;
    background: color-mix(in srgb, var(--brand) 88%, #fff 12%);
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow: 0 8px 20px -12px rgba(var(--brand-rgb), .95), inset 0 1px 0 rgba(255, 255, 255, .24);
    color: #fff;
  }
  .page-header .ph-sync:active {
    transform: scale(.96);
    filter: brightness(.94);
  }
  .page-header .live-dot { font-size: 10.5px; opacity: .9; }

  /* ---- 卡片：伪玻璃 ---- */
  /* 卡片：真模糊 + 斜向高光 + 上下双向内描边，玻璃才有厚度感 */
  .kpi-card,
  .chart-card {
    background-color: rgba(255, 255, 255, .065);
    background-image: linear-gradient(152deg, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, .04) 42%, rgba(255, 255, 255, 0) 68%);
    border: 1px solid var(--g-line);
    border-radius: var(--g-radius);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .20),
      inset 0 -1px 0 rgba(0, 0, 0, .20),
      var(--g-shadow);
    -webkit-backdrop-filter: saturate(165%) blur(16px);
    backdrop-filter: saturate(165%) blur(16px);
  }
  [data-theme="light"] .kpi-card,
  [data-theme="light"] .chart-card {
    background-color: rgba(255, 255, 255, .62);
    background-image: linear-gradient(152deg, rgba(255, 255, 255, .92) 0%, rgba(255, 255, 255, .52) 46%, rgba(255, 255, 255, .38) 100%);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 1),
      inset 0 -1px 0 rgba(15, 23, 42, .06),
      var(--g-shadow);
  }
  .kpi-card::after {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .28), transparent);
    opacity: .8;
  }
  .kpi-card:active {
    transform: scale(.985);
    background: linear-gradient(168deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .055));
    transition: transform .12s ease-out;
  }
  .kpi-label {
    color: color-mix(in srgb, var(--text) 66%, transparent);
    font-size: 11.5px;
    letter-spacing: .2px;
  }
  .kpi-value {
    font-weight: 600;
    letter-spacing: -.45px;
  }
  .kpi-sub { color: color-mix(in srgb, var(--text) 53%, transparent); }
  .chart-card h3 {
    font-weight: 600;
    color: color-mix(in srgb, var(--text) 78%, transparent);
  }
  .chart-card h3::before {
    width: 2px;
    height: 12px;
    border-radius: 1px;
    opacity: .7;
  }

  /* ---- 分组标题：去掉重装饰，只留一条细色标 ---- */
  .ov-group-title {
    border-left-width: 2px;
    border-left-color: color-mix(in srgb, var(--brand) 68%, transparent);
    color: color-mix(in srgb, var(--text) 72%, transparent);
    font-weight: 600;
    letter-spacing: .3px;
  }

  /* ---- 快捷胶囊 ---- */
  .m-chips { padding-bottom: 12px; }
  .m-chips button {
    height: 30px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--g-line);
    background: var(--g-surface);
    box-shadow: var(--g-inset);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: color-mix(in srgb, var(--text) 70%, transparent);
    font-size: 12px;
    font-weight: 500;
    transition: transform .18s cubic-bezier(.32, .72, 0, 1), background .2s, color .2s, border-color .2s;
  }
  .m-chips button:active { transform: scale(.94); }
  .m-chips button.on {
    background: linear-gradient(180deg, rgba(var(--brand-rgb), .34), rgba(var(--brand-rgb), .20));
    border-color: rgba(var(--brand-rgb), .55);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 4px 14px -8px rgba(var(--brand-rgb), .9);
  }
  [data-theme="light"] .m-chips button.on {
    background: color-mix(in srgb, var(--brand) 72%, #1a1206 28%);
    border-color: rgba(255, 255, 255, .45);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 4px 12px -8px rgba(120, 92, 40, .9);
  }
  [data-theme="light"] .page-header .ph-sync {
    background: color-mix(in srgb, var(--brand) 72%, #1a1206 28%);
    border-color: rgba(255, 255, 255, .45);
  }

  /* ---- 底部标签栏：真玻璃 + 可隐藏 ---- */
  .m-tabbar {
    background: color-mix(in srgb, var(--bg2) 58%, transparent);
    backdrop-filter: saturate(180%) blur(38px);
    -webkit-backdrop-filter: saturate(180%) blur(38px);
    border-top: 1px solid var(--g-line);
    box-shadow: 0 -12px 34px -22px rgba(0, 0, 0, .9);
    transition: transform .34s cubic-bezier(.32, .72, 0, 1), opacity .22s ease;
    will-change: transform;
  }
  /* 下滑隐藏、上滑回来 */
  .m-tabbar.m-hide {
    transform: translate3d(0, calc(100% + 10px), 0);
    opacity: 0;
    pointer-events: none;
  }
  .m-tabbar button {
    color: color-mix(in srgb, var(--text) 56%, transparent);
    font-size: 10px;
    font-weight: 500;
    transition: color .18s, transform .18s cubic-bezier(.32, .72, 0, 1);
  }
  .m-tabbar button:active { transform: scale(.9); }
  .m-tabbar button.on {
    color: var(--brand);
    font-weight: 600;
  }
  /* 选中态：图标背后的柔光胶囊，不再用发光横线 */
  .m-tabbar button.on::before {
    content: '';
    position: absolute;
    top: 4px;
    width: 42px;
    height: 26px;
    border-radius: 13px;
    background: radial-gradient(62% 72% at 50% 50%, rgba(var(--brand-rgb), .42), rgba(var(--brand-rgb), 0) 74%);
    box-shadow: none;
  }

  /* ---- 抽屉：玻璃面板 ---- */
  .app .sidebar {
    background: color-mix(in srgb, var(--bg2) 76%, transparent);
    backdrop-filter: saturate(180%) blur(30px);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
    border-right: 1px solid var(--g-line);
  }
  .app .sidebar.open { box-shadow: 24px 0 60px -30px rgba(0, 0, 0, .9); }
  .sidebar-close {
    border: 1px solid var(--g-line);
    background: var(--g-surface);
    box-shadow: var(--g-inset);
    border-radius: 12px;
  }
  .sidebar .nav-search input {
    background: var(--g-surface);
    border: 1px solid var(--g-line);
    border-radius: 12px;
    box-shadow: var(--g-inset);
  }

  /* ---- 登录页：手机端也换成玻璃卡 ---- */
  .login-wrap { background: transparent; padding: 0 16px; }
  .login-card {
    background: var(--g-surface);
    border: 1px solid var(--g-line-strong);
    border-radius: 28px;
    box-shadow: var(--g-inset), 0 30px 70px -40px rgba(0, 0, 0, .95);
    backdrop-filter: saturate(180%) blur(26px);
    -webkit-backdrop-filter: saturate(180%) blur(26px);
    padding: 38px 30px 30px;
    /* app.css 的 ≤480px 分支把 max-width 置为 none、宽度 94%，卡片会贴边；
       这里收回为「不限宽但左右至少留 16px」 */
    width: 100%;
    max-width: 400px;
  }
  .login-card h1 { letter-spacing: .5px; font-weight: 600; }
  .login-card .login-tagline { letter-spacing: 3px; }
  .login-card input {
    background: var(--g-surface);
    border: 1px solid var(--g-line);
    border-radius: 14px;
    box-shadow: var(--g-inset);
  }
  .login-card .login-submit {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .22);
    box-shadow: 0 10px 26px -14px rgba(var(--brand-rgb), .95), inset 0 1px 0 rgba(255, 255, 255, .3);
  }

  /* iOS 质感：按压一律用短促弹性缩放 */
  .btn,
  .page-header .ph-sync,
  .m-chips button,
  .m-tabbar button {
    -webkit-tap-highlight-color: transparent;
  }

  /* ---------- 10b. 内嵌 iframe 模块：让 iframe 让出底栏高度 -----------------
     子页面自带工具栏/底栏，直接 100vh 会被底部标签栏压住；
     这里把它压缩成「应用栏以下、标签栏以上」的内容区，底部栏就能常驻。 */
  .main.iframe-mode {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }
  .main.iframe-mode .section iframe {
    height: calc(100dvh - var(--m-appbar) - var(--m-safe-t) - var(--m-tabbar) - var(--m-safe-b)) !important;
  }

  /* ---------- 10c. 「更多」底部面板（一级科目全集） ------------------------- */
  .m-sheet-mask {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .24s ease, visibility .24s;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
  .m-sheet-mask.show { opacity: 1; visibility: visible; }

  .m-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1201;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    background: color-mix(in srgb, var(--bg2) 92%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
    backdrop-filter: saturate(180%) blur(30px);
    border-top: 1px solid var(--g-line-strong);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -20px 50px -24px rgba(0, 0, 0, .95);
    transform: translate3d(0, 100%, 0);
    transition: transform .34s cubic-bezier(.32, .72, 0, 1);
    padding-bottom: var(--m-safe-b);
  }
  .m-sheet.show { transform: translate3d(0, 0, 0); }

  .m-sheet-grip {
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--text) 26%, transparent);
    margin: 8px auto 2px;
    flex: 0 0 auto;
  }
  .m-sheet-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 10px;
    flex: 0 0 auto;
  }
  .m-sheet-search {
    flex: 1 1 auto;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--g-line);
    background: var(--g-surface);
    box-shadow: var(--g-inset);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
  }
  .m-sheet-search::placeholder { color: color-mix(in srgb, var(--text) 40%, transparent); }
  .m-sheet-done {
    flex: 0 0 auto;
    height: 38px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: color-mix(in srgb, var(--brand) 88%, #fff 12%);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
  }
  .m-sheet-done:active { transform: scale(.96); }

  .m-sheet-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0 12px 8px;
  }

  .m-sheet-group { margin-bottom: 6px; }
  .m-sheet-row {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 8px;
    border-radius: 12px;
  }
  .m-sheet-row:active { background: rgba(var(--brand-rgb), .10); }
  .m-sheet-ic {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .m-sheet-ic svg { width: 100%; height: 100%; }
  .m-sheet-nm {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .m-sheet-cnt {
    flex: 0 0 auto;
    font-size: 11px;
    color: color-mix(in srgb, var(--text) 38%, transparent);
    font-variant-numeric: tabular-nums;
  }
  .m-sheet-pin {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: color-mix(in srgb, var(--text) 34%, transparent);
    font-size: 17px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .m-sheet-pin.on { color: #f5b73d; }
  .m-sheet-pin:active { background: rgba(var(--brand-rgb), .12); }
  .m-sheet-exp {
    flex: 0 0 auto;
    width: 30px;
    height: 34px;
    border: 0;
    background: transparent;
    color: color-mix(in srgb, var(--text) 44%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .22s ease;
  }
  .m-sheet-exp svg { width: 12px; height: 12px; }
  .m-sheet-group.open .m-sheet-exp { transform: rotate(90deg); }

  .m-sheet-items {
    display: none;
    padding: 2px 0 8px 34px;
  }
  .m-sheet-group.open .m-sheet-items { display: block; }
  .m-sheet-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: color-mix(in srgb, var(--text) 76%, transparent);
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    padding: 12px 10px;
    border-radius: 10px;
    min-height: 42px;
  }
  .m-sheet-item[hidden] { display: none; }
  .m-sheet-item:active { background: rgba(var(--brand-rgb), .12); }
  .m-sheet-item.cur {
    color: var(--brand);
    font-weight: 600;
    background: rgba(var(--brand-rgb), .10);
  }
  .m-sheet-empty,
  .m-sheet-tip {
    text-align: center;
    font-size: 11.5px;
    color: color-mix(in srgb, var(--text) 40%, transparent);
    padding: 14px 8px 6px;
    line-height: 1.7;
  }
  body.m-sheet-open { overflow: hidden; }

  /* ---------- 14. 加载占位：数据未到时不要留一片空 ----------
     用两个伪元素摆成和真实 KPI 一样的双列，避免「一片空白」被误认为页面坏了 */
  .kpi-grid:empty {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--m-gap);
    min-height: 0 !important;
    border: 0;
    background: none;
  }
  .kpi-grid:empty::before,
  .kpi-grid:empty::after {
    content: '';
    height: 74px;
    border-radius: var(--g-radius);
    border: 1px solid var(--g-line);
    background:
      linear-gradient(100deg, rgba(255, 255, 255, .035) 30%, rgba(255, 255, 255, .11) 50%, rgba(255, 255, 255, .035) 70%);
    background-size: 300% 100%;
    animation: mSkeleton 1.5s ease-in-out infinite;
  }
  .kpi-grid:empty::after { animation-delay: .18s; }
  @keyframes mSkeleton {
    0% { background-position: 100% 0; }
    100% { background-position: 0 0; }
  }
  @media (prefers-reduced-motion: reduce) {
    .mobile-title { filter: none; }
    .kpi-grid:empty::before,
    .kpi-grid:empty::after { animation: none; }
  }

  /* ---------- 10d. 日间 / 夜间切换滑块 ---------------------------------- */
  .m-skin-switch {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    width: 78px;
    height: 34px;
    padding: 3px;
    margin: 0 2px 0 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg2) 58%, transparent);
    border: 1px solid var(--g-line);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  [data-theme="light"] .m-skin-switch {
    background: rgba(255, 255, 255, .72);
    border-color: var(--g-line-strong);
  }
  .m-skin-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: 28px;
    border-radius: 999px;
    background: linear-gradient(135deg, #e6c878 0%, #b8934c 55%, #9a7838 100%);
    box-shadow: 0 3px 10px -3px rgba(154, 120, 56, .85), inset 0 1px 0 rgba(255, 255, 255, .55);
    transform: translate3d(0, 0, 0);
    transition: transform .34s cubic-bezier(.32, .72, 0, 1), background .3s ease, box-shadow .3s ease;
    z-index: 0;
  }
  .m-skin-switch.is-night .m-skin-thumb {
    transform: translate3d(100%, 0, 0);
    background: linear-gradient(135deg, #c084fc 0%, #a855f7 55%, #6d28d9 100%);
    box-shadow: 0 3px 12px -3px rgba(139, 92, 246, .9), inset 0 1px 0 rgba(255, 255, 255, .4);
  }
  .m-skin-seg {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    min-width: 0;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: none;
    padding: 0;
    font-family: inherit;
    font-size: 0;              /* 纯图标，文字已去掉 */
    color: color-mix(in srgb, var(--text) 50%, transparent);
    transition: color .2s ease;
    cursor: pointer;
  }
  .m-skin-seg svg { width: 16px; height: 16px; flex: 0 0 auto; }
  .m-skin-seg.on { color: #fff; }
  /* 日间滑块是浅金，白字压不住 → 换深棕；夜间紫块继续用白字 */
  .m-skin-switch.is-day .m-skin-seg.on { color: #3a2a10; }
  .m-skin-seg:active { transform: scale(.96); }

  /* ---------- 10e. 全屏搜索 ------------------------------------------------ */
  .mobile-header .mobile-search-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: none;
    border-radius: 12px;
    color: var(--text);
    padding: 0;
    margin-left: auto;
    cursor: pointer;
    transition: transform .18s cubic-bezier(.32, .72, 0, 1), background .18s;
  }
  .mobile-header .mobile-search-btn:active {
    background: rgba(255, 255, 255, .10);
    transform: scale(.92);
  }

  .m-search {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: flex;
    flex-direction: column;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
    backdrop-filter: saturate(180%) blur(30px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity .2s ease, transform .26s cubic-bezier(.32, .72, 0, 1), visibility .2s;
    padding-top: var(--m-safe-t);
  }
  .m-search.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .m-search-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 10px;
    flex: 0 0 auto;
  }
  .m-search-field {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .10);
    border: 1px solid var(--g-line);
    box-shadow: var(--g-inset);
  }
  [data-theme="light"] .m-search-field {
    background: rgba(15, 23, 42, .06);
    border-color: var(--g-line-strong);
  }
  .m-search-field svg { width: 17px; height: 17px; flex: 0 0 auto; color: color-mix(in srgb, var(--text) 45%, transparent); }
  .m-search-field input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    height: 100%;
  }
  .m-search-field input::placeholder { color: color-mix(in srgb, var(--text) 38%, transparent); }
  .m-search-field input::-webkit-search-cancel-button { display: none; }
  .m-search-clear {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--text) 22%, transparent);
    color: var(--bg);
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
  }
  .m-search-field.has-value .m-search-clear { opacity: 1; pointer-events: auto; }
  .m-search-cancel {
    flex: 0 0 auto;
    border: 0;
    background: none;
    color: var(--brand);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 2px;
    cursor: pointer;
  }

  .m-search-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 2px 10px calc(20px + var(--m-safe-b));
  }
  .m-search-cap {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .4px;
    color: color-mix(in srgb, var(--text) 45%, transparent);
    padding: 14px 8px 6px;
  }
  .m-search-row {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 50px;
    padding: 8px 10px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
  }
  .m-search-row:active { background: rgba(var(--brand-rgb), .12); }
  .m-search-ic {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    color: var(--brand);
  }
  .m-search-ic svg { width: 100%; height: 100%; }
  .m-search-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .m-search-txt b { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-search-txt i {
    font-style: normal;
    font-size: 11px;
    color: color-mix(in srgb, var(--text) 42%, transparent);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .m-search-badge {
    flex: 0 0 auto;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 999px;
    color: color-mix(in srgb, var(--text) 55%, transparent);
    background: color-mix(in srgb, var(--text) 10%, transparent);
  }
  .m-search-empty {
    text-align: center;
    font-size: 12.5px;
    line-height: 1.8;
    color: color-mix(in srgb, var(--text) 42%, transparent);
    padding: 40px 24px;
  }
  body.m-search-open { overflow: hidden; }

  /* ---------- 11. 横屏（高度优先断点） ---------------------------------- */
  @media (orientation: landscape) and (max-height: 480px) {
    :root { --m-appbar: 46px; --m-filter: 40px; }
    .m-tabbar { display: none; }
    .main { padding-bottom: 16px; }
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .kpi-card { min-height: 64px; }
    .kpi-value { font-size: 17px; }
  }

  /* ---------- 12. 系统偏好：减少动效 ------------------------------------ */
  @media (prefers-reduced-motion: reduce) {
    .app .sidebar { transition: none; }
    .m-chips button:active { transform: none; }
  }
}

/* ==========================================================================
   ≤ 360px：小屏兜底，避免双列挤压溢出
   ========================================================================== */
@media (max-width: 360px) {
  .kpi-value { font-size: 17px !important; }
  .kpi-card { padding: 10px; }
  .date-bar select { max-width: 104px; }
  .page-header h1 { font-size: 16px; }
}

/* ==========================================================================
   安装版（PWA / 添加到主屏幕）运行时的差异适配
   --------------------------------------------------------------------------
   背景：以 standalone 方式启动后，浏览器地址栏消失，页面直抵物理屏幕边缘。
   此时 env(safe-area-inset-top) 通常才真正生效（普通标签页里多为 0），
   顶部应用栏必须自己把状态栏高度补回来，否则标题、搜索、菜单会被
   鸿蒙/安卓的状态栏文字压住。
   仅在独立窗口模式生效，普通浏览器访问完全不受影响。
   ========================================================================== */
@media (display-mode: standalone), (display-mode: minimal-ui) {
  /* 顶部：状态栏之下再让出 4px 呼吸空间 */
  .mobile-header {
    padding-top: calc(var(--m-safe-t) + 4px);
    height: calc(var(--m-appbar) + var(--m-safe-t) + 4px);
  }
  /* 底部：手势条之上再让出 2px，避免底栏文字贴边 */
  .m-tabbar {
    padding-bottom: calc(var(--m-safe-b) + 2px);
  }
  .main {
    padding-bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 26px);
  }
  /* 内嵌模块的 iframe 同步让位（含上面为状态栏额外让出的 4px 与手势条 2px） */
  .main.iframe-mode .section iframe {
    height: calc(100dvh - var(--m-appbar) - var(--m-safe-t) - 4px - var(--m-tabbar) - var(--m-safe-b) - 2px) !important;
  }
  /* 独立窗口里没有"下拉刷新"，但误触回弹会让人以为卡住，收掉 */
  body { overscroll-behavior-y: none; }
}

/* iOS Safari 添加到主屏幕后（navigator.standalone）不保证带 display-mode，
   用 -webkit 私有值兜住老版本 */
@media (display-mode: standalone) {
  .login-wrap { padding-top: env(safe-area-inset-top, 0px); }
}

/* 全屏模式下隐藏浏览器的"下拉刷新"提示区（仅安卓 Chrome 系列） */
@media (display-mode: standalone) and (min-height: 600px) {
  html { background-color: #182334; }
}

/* ---------- 启动遮罩：消除 standalone 冷启动的第一帧白屏 ---------- */
/* 默认不显示；只有 <html data-standalone="1">（独立窗口）时才铺满 */
#m-boot { display: none; }
html[data-standalone="1"] #m-boot {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 99999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  background: radial-gradient(72% 56% at 50% 34%, #1d2b42 0%, #131c2a 58%, #0d141f 100%);
  opacity: 1;
  transition: opacity .34s ease;
}
html[data-standalone="1"] #m-boot.hide { opacity: 0; pointer-events: none; }
#m-boot img {
  width: 108px;
  height: 108px;
  object-fit: contain;
  filter: drop-shadow(0 10px 26px rgba(201, 162, 90, .34));
  animation: m-boot-breathe 1.8s ease-in-out infinite;
}
#m-boot .t {
  font-size: 13px;
  letter-spacing: 3px;
  color: rgba(230, 236, 245, .58);
  font-family: 'HarmonyOS Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
@keyframes m-boot-breathe {
  0%, 100% { transform: scale(.96); opacity: .82; }
  50%      { transform: scale(1.03); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #m-boot img { animation: none; }
}

/* ==========================================================================
   期间明细弹窗（配合 m-period-detail.js）
   --------------------------------------------------------------------------
   放在媒体查询外层：弹层本身是 fixed 铺满视口的，规则全局生效更稳；
   触发入口（期间胶囊）只在移动端，所以桌面端不会看到它。
   ========================================================================== */
.pd-mask {
  position: fixed;
  inset: 0;
  z-index: 120;
  visibility: hidden;
  opacity: 0;
  background: rgba(4, 8, 18, .56);
  -webkit-backdrop-filter: blur(3px) saturate(120%);
  backdrop-filter: blur(3px) saturate(120%);
  transition: opacity .24s ease, visibility .24s ease;
}
.pd-mask.open { visibility: visible; opacity: 1; }

.pd-sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 140%, transparent);
  background: color-mix(in srgb, var(--bg2) 94%, transparent);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow: 0 -18px 46px -22px rgba(0, 0, 0, .6);
  transform: translateY(102%);
  transition: transform .36s cubic-bezier(.32, .72, 0, 1);
}
.pd-mask.open .pd-sheet { transform: translateY(0); }

.pd-grab {
  width: 38px; height: 4px;
  margin: 8px auto 2px;
  border-radius: 99px;
  background: var(--border);
  flex: 0 0 auto;
}

.pd-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 16px 12px;
  flex: 0 0 auto;
}
.pd-head-txt { flex: 1 1 auto; min-width: 0; }
.pd-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--text);
}
.pd-sub {
  margin: 3px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pd-close {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pd-close svg { width: 14px; height: 14px; }
.pd-close:active { background: var(--bg3); transform: scale(.94); }

.pd-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 12px;
  flex: 0 0 auto;
}
.pd-tile {
  min-width: 0;
  padding: 8px 10px 9px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg3) 88%, transparent);
}
.pd-tile span {
  display: block;
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pd-tile b {
  display: block;
  margin-top: 3px;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pd-tile.is-skel {
  height: 52px;
  border-color: transparent;
  background: linear-gradient(100deg, var(--bg3) 30%, color-mix(in srgb, var(--bg3) 60%, #fff 12%) 50%, var(--bg3) 70%);
  background-size: 240% 100%;
  animation: pd-skel 1.1s linear infinite;
}
@keyframes pd-skel { from { background-position: 120% 0; } to { background-position: -120% 0; } }

.pd-seg {
  display: none;                 /* 只有「期间明细」才显示，由脚本切到 inline-flex */
  align-self: flex-end;
  margin: -2px 16px 8px auto;
  padding: 2px;
  gap: 2px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg3) 90%, transparent);
}
.pd-seg button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  height: 24px;
  padding: 0 12px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  color: var(--text3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pd-seg button.on {
  background: color-mix(in srgb, var(--brand) 24%, var(--bg2));
  color: color-mix(in srgb, var(--brand) 74%, var(--text));
  font-weight: 600;
}

.pd-chartwrap {
  position: relative;
  height: 186px;
  margin: 0 10px;
  flex: 0 0 auto;
}

.pd-tip {
  padding: 6px 16px 2px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text3);
  flex: 0 0 auto;
}
.pd-tip.is-err { color: var(--red, #e05a63); }

.pd-table {
  margin: 6px 12px 0;
  padding-bottom: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1 1 auto;
  min-height: 0;
}
.pd-table::-webkit-scrollbar { display: none; }
/* 还能往下滚时，底部做一点渐隐，避免最后一行被硬切 */
.pd-table.is-scroll {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
}
.pd-tr {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(0, 1fr) 56px;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text2);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 62%, transparent);
}
.pd-tr span:not(:first-child) { text-align: right; }
.pd-tr span:last-child { color: var(--text); font-weight: 600; }
.pd-th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text3);
  background: color-mix(in srgb, var(--bg2) 96%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.pd-th span { font-weight: 500 !important; color: var(--text3) !important; }
.pd-tr .is-neg { color: var(--red, #e05a63) !important; }
.pd-tr .is-pos { color: var(--green, #3DAE8B) !important; }
/* 增长/下降的语义色：增长标红、下降标绿，与站内「海关数据」页一致（涨=红）*/
.pd-tr .is-up { color: var(--red, #e05a63) !important; }
.pd-tr .is-down { color: var(--green, #3DAE8B) !important; }
/* 期间明细带同比时的五列：月份/营收/去年同期/同比/毛利率 */
.pd-table.cols5 .pd-tr { grid-template-columns: 38px minmax(0, 1fr) minmax(0, 1fr) 46px 50px; }
/* 只有三列的表（应付账期的「账期/余额/环比」） */
.pd-table.cols3 .pd-tr { grid-template-columns: 56px minmax(0, 1fr) 62px; }

body.pd-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .pd-sheet { transition: none; }
  .pd-mask { transition: none; }
  .pd-tile.is-skel { animation: none; }
}

/* ==========================================================================
   经营结果 KPI 卡：点开「月度明细」（配合 m-period-detail.js）
   只在移动端响应；桌面端卡片不可点、也没有任何视觉变化。
   ========================================================================== */
@media (max-width: 820px), (orientation: landscape) and (max-height: 480px) {
  #sec-overview #ov-sales .kpi-card { cursor: pointer; }
  #sec-overview #ov-sales .kpi-card:active { transform: scale(.985); filter: brightness(1.05); }

  /* 期间文字过长时压缩，不要把分组标题撑出容器 */
  #sec-overview .ov-group-title { min-width: 0; }
  #sec-overview .ov-group-title #ov-sales-period {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
}

/* ==========================================================================
   经营总览 · 图表区在移动端整体下线
   --------------------------------------------------------------------------
   资金占用结构 / 应付账龄分布 / 应收账龄分布 / 近12月营收 vs 毛利 / 近6月应付余额 / 近6月应收余额
   这 6 张图的内容，已经由「点 KPI 卡弹出的明细」承载（账龄分布、余额趋势、月度营收毛利），
   手机上再单列一遍既重复又难读（Y 轴还是 6000 万这种长数字）。
   桌面端保持原样，不受影响。
   ========================================================================== */
@media (max-width: 820px), (orientation: landscape) and (max-height: 480px) {
  #sec-overview .ov-charts { display: none !important; }
}

/* ==========================================================================
   期间条 · 销售部 / 事业部快过滤
   --------------------------------------------------------------------------
   只在移动端出现（桌面端 .date-bar-flt 保持 display:none，绝对不影响桌面布局）。
   三枚胶囊铺满一行：期间 + 销售部 + 事业部；右侧那串重复的期间名称收掉腾地方。
   选中后胶囊染品牌色，一眼能看出「现在看的是过滤后的数」。
   ========================================================================== */
.date-bar-flt { display: none; }

@media (max-width: 820px), (orientation: landscape) and (max-height: 480px) {
  .date-bar-right { display: none; }
  .date-bar-left { flex: 0 0 auto; }
  /* 只有经营总览才显示（body.ov-flt-on 由 mobile.js 的 syncChrome 维护）；
     其它模块自己有对应筛选，这两个跟着出现会误导用户以为能筛。 */
  body.ov-flt-on .date-bar-flt {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
  }
  /* 期间胶囊也换成同一枚实心箭头，三枚看起来才是一套 */
  .date-bar #date-preset {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b93a7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 9px 6px;
    background-position: right 11px center;
    background-repeat: no-repeat;
    padding-right: 26px;
  }
  .date-bar .flt-chip {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    height: 34px;
    padding: 0 26px 0 11px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    /* 换成实心小箭头：上面那套双渐变箭头在 34px 高、字号 12.5 的胶囊上几乎看不见 */
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b93a7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 9px 6px;
    background-position: right 11px center;
    background-repeat: no-repeat;
  }
  /* 日间主题是浅金底，白箭头看不清 → 换深棕 */
  [data-theme="light"] .date-bar .flt-chip.is-on {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%233a2a10' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
  .date-bar .flt-chip.is-on {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
  .date-bar .flt-chip.is-on {
    border: 1px solid color-mix(in srgb, var(--brand) 55%, var(--border));
    background-color: color-mix(in srgb, var(--brand) 18%, var(--bg3));
    color: color-mix(in srgb, var(--brand) 74%, var(--text));
    font-weight: 600;
  }
}

/* ==========================================================================
   宽表格：移动端横滑 + 首列冻结
   --------------------------------------------------------------------------
   利润分析（11 列）、库存明细这类表，桌面靠横向空间铺开，手机上只露出第一列，
   后面的数字全被裁掉。这里统一处理所有内嵌模块的表格容器：
   · 容器横向可滚（.table-card 本来就有 overflow-x:auto，其余补上）
   · 首列 sticky 钉住，横滑时「客户名/物料」不跟着跑掉
   · 右缘渐隐提示「右边还有内容」
   ========================================================================== */
@media (max-width: 820px), (orientation: landscape) and (max-height: 480px) {
  .table-card,
  .table-wrap,
  .data-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    /* 右缘渐隐：告诉用户右边还有列 */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 18px), rgba(0, 0, 0, .35));
    mask-image: linear-gradient(to right, #000 calc(100% - 18px), rgba(0, 0, 0, .35));
  }
  /* 表格保持自然宽度（不压缩），让列不被挤成一列一个字的窄条 */
  .table-card table,
  .table-wrap table {
    min-width: max-content;
    /* border-collapse:collapse 下 Chrome 会忽略表头/单元格的 position:sticky，
       首列冻结就失效（实测：能横滑但名称列跟着跑、还被后面的列压住）。
       拆成 separate 后 sticky 才生效；边框本来就画在单元格自身上，视觉一致。 */
    border-collapse: separate;
    border-spacing: 0;
  }
  /* 首列冻结 */
  .table-card table th:first-child,
  .table-card table td:first-child,
  .table-wrap table th:first-child,
  .table-wrap table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg2);
    box-shadow: 1px 0 0 var(--border);
  }
  .table-card table thead th:first-child,
  .table-wrap table thead th:first-child {
    z-index: 3;
    background: var(--bg2);
  }
  /* 首列名称过长时截断，否则一列能撑到屏幕外 */
  .table-card table td:first-child,
  .table-wrap table td:first-child {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
