/**
 * APP 原型：375 逻辑宽
 * - 真机 / 窄屏（<768）：全屏 100dvh，Tab 固定贴屏幕底
 * - PC 宽屏（≥768）：居中 375×812 设备框（无模拟状态栏，真机用系统栏）
 */

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overflow-x: hidden;
}

body.app-device {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  height: 100dvh;
  max-height: 100dvh;
  background: #f5f7fa;
  overflow: hidden;
  overflow-x: hidden;
  box-sizing: border-box;
}

body.app-device:not(.app-login-page) {
  display: flex;
  flex-direction: column;
}

.app-shell,
.app-device-frame {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background: #f5f7fa;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* —— 真机 / 平板竖屏：Tab 固定底部 —— */
@media (max-width: 767px) {
  .app-nav {
    padding-top: env(safe-area-inset-top, 0);
    min-height: calc(var(--app-nav-height) + env(safe-area-inset-top, 0));
    height: auto;
  }

  .app-shell--tabs .app-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    margin-top: 0;
    z-index: 100;
  }

  .app-shell--tabs .app-body {
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: calc(var(--app-tabbar-height) + env(safe-area-inset-bottom, 0px) + 8px);
  }
}

/* —— PC 预览：375×812 画板（页面不滚动，仅内容区滚动） —— */
@media (min-width: 768px) {
  html {
    height: 100vh;
    max-height: 100vh;
  }

  body.app-device {
    height: 100vh;
    max-height: 100vh;
    min-height: 0;
    background: #dcdcdc;
  }

  body.app-device:not(.app-login-page) {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 16px;
  }

  .app-shell,
  .app-device-frame {
    width: var(--app-width);
    max-width: var(--app-width);
    flex: 0 0 auto;
    height: min(var(--app-height), calc(100vh - 32px));
    min-height: 0;
    max-height: min(var(--app-height), calc(100vh - 32px));
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-radius: 24px;
  }

  /* PC 画板内 Tab 参与 flex，不 fixed；不模拟 Home 条留白 */
  .app-shell--tabs .app-tabbar {
    position: static;
    padding-bottom: 0;
  }

  .app-shell--tabs .app-body {
    padding-bottom: 8px;
  }

  .app-tabbar {
    border-radius: 0 0 24px 24px;
  }
}

.app-nav {
  height: var(--app-nav-height);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 17px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  position: relative;
}

.app-nav .scan {
  position: absolute;
  right: 12px;
  font-size: var(--font-size-sm);
  font-weight: normal;
  color: var(--color-primary);
}

.app-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.app-nav,
.app-profile-header {
  flex-shrink: 0;
}

.app-tabbar {
  box-sizing: border-box;
  background: #fff;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-shrink: 0;
  margin-top: auto;
  align-items: flex-start;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: var(--app-tabbar-height);
  min-height: var(--app-tabbar-height);
  font-size: 10px;
  color: var(--text-tertiary);
  gap: 2px;
  text-decoration: none;
}

.app-tabbar a.active {
  color: var(--color-primary);
}

.app-tabbar .icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: currentColor;
  opacity: 0.25;
}

.app-tabbar a.active .icon {
  opacity: 1;
}

.app-summary {
  display: flex;
  gap: 8px;
  padding: 12px;
}

.app-summary .item {
  flex: 1;
  background: #fff;
  border-radius: var(--radius-app-card);
  padding: 10px 6px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.app-summary .num {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
}

.app-summary .lbl {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.app-grid-section {
  margin: 0 12px 12px;
  padding: 14px 10px 8px;
  background: linear-gradient(180deg, #1890ff 0%, #40a9ff 100%);
  border-radius: var(--radius-app-card);
}

.app-grid-section .title {
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--font-size-sm);
  margin-bottom: 12px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 6px;
}

.app-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
}

.app-grid-item .gi {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.app-list-section {
  margin: 0 12px;
}

.app-list-section h3 {
  font-size: 14px;
  margin: 0 0 10px 4px;
  color: var(--text-secondary);
}

.app-todo-card {
  background: #fff;
  border-radius: var(--radius-app-card);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
}

.app-todo-card .top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.app-todo-card .title {
  font-weight: 600;
  font-size: 14px;
}

.app-todo-card .meta {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
}

/* 工作台 · 赛飞特风：模块标题 + 图标宫格（非列表） */
.app-workbench {
  padding: 8px 0 16px;
}

.app-wb-section {
  margin: 0 12px 12px;
  background: #fff;
  border-radius: var(--radius-app-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.app-wb-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.app-wb-title::before {
  content: "";
  width: 3px;
  height: 16px;
  background: var(--color-primary);
  border-radius: 2px;
  flex-shrink: 0;
}

.app-wb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px 0;
  padding: 4px 8px 16px;
}

.app-wb-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 11px;
  text-align: center;
  line-height: 1.3;
}

.app-wb-item .ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(145deg, #1890ff, #096dd9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
}

.app-wb-item.muted .ico {
  background: linear-gradient(145deg, #69c0ff, #1890ff);
  font-size: 16px;
}

.app-msg-item {
  display: flex;
  gap: 12px;
  padding: 14px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
}

.app-msg-item.unread .dot {
  width: 8px;
  height: 8px;
  background: var(--risk-red);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.app-profile-header {
  background: linear-gradient(135deg, #1890ff, #096dd9);
  padding: 24px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0));
  color: #fff;
  flex-shrink: 0;
}

.app-profile-header .name {
  font-size: 18px;
  font-weight: 600;
}

.app-profile-header .dept {
  font-size: var(--font-size-sm);
  opacity: 0.85;
  margin-top: 4px;
}

.app-menu-list {
  margin: 12px;
  background: #fff;
  border-radius: var(--radius-app-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.app-menu-list a {
  display: block;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.app-menu-list a:last-child {
  border-bottom: none;
}

.tag {
  display: inline-block;
  padding: 0 8px;
  height: 20px;
  line-height: 20px;
  border-radius: var(--radius-base);
  font-size: 11px;
}

.tag-blue {
  background: #e6f7ff;
  color: #0958d9;
}

.tag-orange {
  background: #fff7e6;
  color: var(--risk-orange);
}

.tag-green {
  background: #f6ffed;
  color: #52c41a;
}

/* 现场闭环页（列表 / 表单 / 步骤） */
.app-page-list .app-list-item {
  display: block;
  margin: 0 12px 10px;
  padding: 14px;
  background: #fff;
  border-radius: var(--radius-app-card);
  box-shadow: var(--shadow-card);
  color: var(--text-primary);
  text-decoration: none;
}

.app-page-list .app-list-item .t {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.app-page-list .app-list-item .m {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

.app-flow-form {
  padding: 12px 16px 24px;
}

.app-flow-form .fg {
  margin-bottom: 14px;
}

.app-flow-form label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.app-flow-form label.req::after {
  content: " *";
  color: var(--risk-red);
}

.app-flow-form .input,
.app-flow-form select,
.app-flow-form textarea {
  width: 100%;
}

.app-flow-form textarea {
  min-height: 72px;
  padding: 8px 11px;
  border: 1px solid #d9d9d9;
  border-radius: var(--radius-base);
  font-family: inherit;
  font-size: 14px;
}

.app-photo-box {
  border: 1px dashed #d9d9d9;
  border-radius: var(--radius-base);
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 13px;
  background: #fafafa;
}

.app-step-bar {
  display: flex;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  font-size: 11px;
}

.app-step-bar span {
  flex: 1;
  text-align: center;
  color: var(--text-tertiary);
}

.app-step-bar span.on {
  color: var(--color-primary);
  font-weight: 600;
}

.app-footer-actions {
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  background: #fff;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
}

.app-footer-actions .btn {
  flex: 1;
  height: 44px;
}

.app-shell--flow .app-body {
  padding-bottom: 0;
}

.app-result {
  text-align: center;
  padding: 48px 24px;
}

.app-result .ok {
  font-size: 48px;
  color: #52c41a;
  margin-bottom: 12px;
}

.app-filter-tabs,
.app-subtabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.app-filter-tabs span,
.app-subtabs a {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
}

.app-filter-tabs span {
  cursor: pointer;
}

.app-filter-tabs span.on,
.app-subtabs a.on {
  color: var(--color-primary);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--color-primary);
}

.app-subtabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.app-subtabs a {
  flex: 0 0 auto;
  min-width: 72px;
  font-size: 12px;
  padding: 10px 12px;
}

.app-pdf-viewer {
  margin: 12px;
  background: #fff;
  border-radius: var(--radius-app-card);
  box-shadow: var(--shadow-card);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 13px;
  gap: 8px;
}

.app-timer-bar {
  background: #fff;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.app-timer-bar strong {
  color: var(--color-primary);
  font-size: 18px;
}

.app-exam-head {
  background: #fff6;
  background: #fff;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.app-exam-head .countdown {
  color: var(--risk-red);
  font-weight: 600;
}

.app-q-card {
  margin: 12px;
  padding: 14px;
  background: #fff;
  border-radius: var(--radius-app-card);
  box-shadow: var(--shadow-card);
}

.app-q-card .q-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.app-q-card label {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  font-size: 14px;
  align-items: flex-start;
}

.app-map-stub {
  margin: 12px;
  height: 160px;
  background: linear-gradient(135deg, #e6f7ff, #f0f5ff);
  border-radius: var(--radius-app-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 12px;
  border: 1px dashed #91d5ff;
}
