/* ==================================================================
   PWA / 手机 APP 外壳
   ================================================================== */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 22%, #0b2038 0, #04080f 58%);
  transition: opacity .42s ease, visibility .42s ease;
}
.app-splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.app-splash-inner { text-align: center; transform: translateY(-8px); }
.app-splash-inner img {
  width: 88px; height: 88px; border-radius: 22px;
  box-shadow: 0 16px 44px rgba(0, 183, 255, .25), 0 0 0 1px rgba(127, 228, 255, .16);
}
.app-splash-name { margin-top: 16px; color: #e8f6ff; font-size: 19px; font-weight: 700; letter-spacing: 2px; }
.app-splash-sub { margin-top: 5px; color: #4d7897; font-size: 9px; letter-spacing: 3px; }
.app-splash-dots { display: flex; justify-content: center; gap: 5px; margin-top: 22px; }
.app-splash-dots i { width: 5px; height: 5px; border-radius: 50%; background: #3fd1ff; animation: appdot 1.1s infinite ease-in-out; }
.app-splash-dots i:nth-child(2) { animation-delay: .16s; opacity: .8; }
.app-splash-dots i:nth-child(3) { animation-delay: .32s; opacity: .6; }
@keyframes appdot { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-5px); opacity: 1; } }

.mobile-tabbar { display: none; }

.mobile-me-head {
  display: flex; align-items: center; gap: 13px;
  padding: 4px 0 16px; border-bottom: 1px solid var(--line-soft); margin-bottom: 14px;
}
.mobile-me-avatar {
  width: 50px; height: 50px; border-radius: 50%; flex: 0 0 50px;
  display: grid; place-items: center; color: #04101e; font-size: 19px; font-weight: 800;
  background: linear-gradient(135deg, #7fe4ff, #2e7cff);
  box-shadow: 0 6px 18px rgba(46, 124, 255, .28);
}
.mobile-me-name { font-size: 16px; font-weight: 700; color: var(--text-1); }
.mobile-me-role { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.mobile-me-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mobile-me-item {
  display: flex; align-items: center; gap: 9px; min-height: 46px; padding: 0 12px;
  border: 1px solid var(--line-soft); border-radius: 10px; background: rgba(255,255,255,.025);
  color: var(--text-1); font-size: 12.5px; text-align: left; cursor: pointer;
}
.mobile-me-item svg { color: var(--cyan); flex: 0 0 auto; }
.mobile-me-item:active { background: rgba(53, 208, 255, .08); }
.mobile-install-btn { width: 100%; margin-top: 14px; }
.mobile-logout-btn { width: 100%; margin-top: 8px; color: var(--red) !important; }
.mobile-installed {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 14px; padding: 10px; border-radius: 9px;
  color: var(--green); font-size: 12px; background: rgba(53, 217, 143, .07);
  border: 1px solid rgba(53, 217, 143, .18);
}
.mobile-version { text-align: center; color: var(--text-3); font-size: 10px; margin-top: 14px; }
.mobile-install-help { font-size: 12.5px; line-height: 1.9; color: var(--text-2); }
.mobile-install-help p { margin: 0 0 10px; }
.mobile-install-help b { color: var(--text-1); }

@media (max-width: 640px) {
  .main { height: 100dvh; }
  .topbar {
    height: calc(58px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    padding-left: 12px; padding-right: 12px;
    gap: 8px;
  }
  .topbar .crumb span:first-child, .topbar .crumb .sep { display: none; }
  .topbar .crumb b { font-size: 15px; }
  .topbar .live-pill, .topbar .clock { display: none; }
  .topbar .user-meta { display: none; }
  .topbar .user-chip { padding: 3px; gap: 0; }
  .topbar .user-chip > span:last-child { display: none; }
  .topbar .top-actions { gap: 6px; }
  .topbar .icon-btn { width: 34px; height: 34px; }
  .content { padding: 12px 12px calc(78px + env(safe-area-inset-bottom)); }
  .page-head { align-items: flex-start; gap: 10px; }
  .page-title { font-size: 18px; }
  .page-sub { font-size: 11px; line-height: 1.6; }
  .page-tools { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .page-tools .btn { flex: 0 0 auto; min-height: 34px; padding: 0 11px; font-size: 11px; }
  .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  .report-kpi { padding: 11px 12px; }
  .report-kpi .k { font-size: 10px; }
  .report-kpi .v { font-size: 25px; margin-top: 2px; }
  .report-kpi .kpi-icon { width: 24px !important; height: 24px !important; }
  .card { border-radius: 11px; }
  .card-hd { padding: 12px 13px; }
  .card-bd { padding: 12px 13px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table th, .table td { padding-left: 10px; padding-right: 10px; }
  .grid { gap: 10px; }
  .col-5, .col-4, .col-3, .col-7, .col-8, .col-9 { grid-column: span 12; }
  .modal { width: calc(100vw - 18px) !important; max-height: calc(100dvh - 24px); border-radius: 13px; }
  .modal-body { padding: 14px; }
  .modal-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .toast-root { left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); }
  .toast { width: auto; max-width: none; }

  .mobile-tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    height: calc(58px + env(safe-area-inset-bottom));
    padding: 5px 6px env(safe-area-inset-bottom);
    background: rgba(6, 16, 29, .93);
    border-top: 1px solid rgba(115, 165, 205, .14);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .3);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .mtab {
    position: relative;
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: #6f87a2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 3px 0;
    font-size: 10px;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mtab svg { width: 21px; height: 21px; stroke-width: 1.7; }
  .mtab span { line-height: 1.2; white-space: nowrap; }
  .mtab.active { color: #5fe0ff; }
  .mtab.active::before {
    content: "";
    position: absolute;
    top: -5px; left: 50%; transform: translateX(-50%);
    width: 22px; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, transparent, #5fe0ff, transparent);
    box-shadow: 0 0 10px rgba(95, 224, 255, .7);
  }
  .mtab:active { color: #c4f4ff; }
}

@media (max-width: 380px) {
  .mtab { font-size: 9px; }
  .mtab svg { width: 19px; height: 19px; }
  .report-kpi .v { font-size: 22px; }
}

@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .topbar { height: calc(58px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .app-splash-inner img { box-shadow: 0 16px 50px rgba(0, 183, 255, .32), 0 0 0 1px rgba(127, 228, 255, .2); }
}

/* 财务角色：只保留合同入口，不显示移动端底部导航 */
body[data-role="finance"] .mobile-tabbar { display: none !important; }
body[data-role="finance"] .content { padding-bottom: 12px; }

/* 使用单位角色：隐藏无关的视频 Tab */
body[data-role="unit"] .mtab[data-path="/cameras"] { display: none; }
