:root {
  --primary: #1f6feb;
  --primary-dark: #1452b5;
  --green: #16a34a;
  --red: #dc2626;
  --gray: #9ca3af;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1f2937;
  --text-sub: #6b7280;
  --border: #e5e7eb;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* 确保 hidden 属性始终生效，不被 display:flex 等覆盖 */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--primary); color: #fff;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar .sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.topbar-user { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.topbar-user .tu-company { background: rgba(255,255,255,.25); padding: 1px 8px; border-radius: 10px; font-weight: 600; }
.topbar-user .tu-name { font-weight: 600; }
.topbar-user .tu-role { opacity: .85; background: rgba(255,255,255,.2); padding: 1px 8px; border-radius: 10px; }
.topbar-user .tu-logout {
  border: 1px solid rgba(255,255,255,.6); background: transparent; color: #fff;
  border-radius: 12px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}

/* 登录页 */
.login-wrap { max-width: 380px; margin: 40px auto 0; text-align: center; }
.login-logo { font-size: 52px; }
.login-wrap h2 { font-size: 20px; margin: 8px 0 4px; }
.login-sub { font-size: 13px; color: var(--text-sub); margin-bottom: 24px; }
.login-wrap .field { text-align: left; }
.login-tip { font-size: 12px; color: var(--gray); margin-top: 18px; }

/* 外网隧道地址展示 */
.tunnel-box {
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
  padding: 10px; margin-bottom: 12px;
}
.tunnel-url {
  font-size: 13px; word-break: break-all; color: var(--primary);
  font-weight: 600; margin: 4px 0 8px;
}

/* 记录查询列表 */
.hist-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.hist-item:last-child { border-bottom: none; }
.hist-head { display: flex; align-items: center; gap: 8px; }
.hist-type {
  font-size: 11px; padding: 1px 8px; border-radius: 10px;
  background: #e0e7ff; color: #3730a3;
}
.hist-date { font-size: 12px; color: var(--text-sub); }
.hist-title { font-size: 14px; margin-top: 4px; }
.hist-meta { font-size: 12px; color: var(--text-sub); margin-top: 3px; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.pager-info { font-size: 13px; color: var(--text-sub); }

/* 安装引导条 */
.install-banner {
  background: #eff6ff; border: 1px solid #bfdbfe; color: var(--primary);
  font-size: 14px; text-align: center; cursor: pointer; font-weight: 600;
}
.install-banner.warn { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* 保存位置单选 */
.radio-row { display: flex; gap: 16px; }
.radio-item { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--text); }

/* 文件夹选择器 */
.picker-path {
  font-size: 13px; color: var(--primary); background: #eff6ff;
  border-radius: 6px; padding: 8px 10px; word-break: break-all; margin-bottom: 8px;
}
.picker-list {
  max-height: 44vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px;
}
.picker-item {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 14px; cursor: pointer;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:active { background: #eff6ff; }

/* 徽标 */
.badge.ok-badge { background: #dcfce7; color: #166534; }
.badge.rej-badge { background: #fee2e2; color: #b91c1c; }

/* 禁用态 */
.mark-btn.disabled { opacity: .55; cursor: not-allowed; }

/* 审核 */
.review-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.review-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.review-item:last-child { border-bottom: none; }
.rv-title { font-size: 14px; font-weight: 500; }
.rv-meta { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.rv-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn.small.ok { background: #dcfce7; color: #166534; }
.btn.small.bad { background: #fee2e2; color: #b91c1c; }

/* 主内容 */
#view { flex: 1; padding: 12px 12px 140px; overflow-y: auto; }

/* 底部 Tab */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px;
  display: flex; background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tabbar .tab {
  flex: 1; text-align: center; padding: 8px 0 6px; color: var(--gray);
  font-size: 11px; cursor: pointer; text-decoration: none;
}
.tabbar .tab .ico { font-size: 20px; display: block; line-height: 1.2; }
.tabbar .tab.active { color: var(--primary); }

/* 卡片 */
.card {
  background: var(--card); border-radius: 12px; padding: 14px;
  margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card h3 { font-size: 15px; margin-bottom: 10px; }

/* 可选配置卡片（折叠，默认收起） */
details.card > summary.opt-summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 15px; font-weight: 600;
}
details.card > summary.opt-summary::-webkit-details-marker { display: none; }
.opt-state { font-size: 12px; color: var(--text-sub); font-weight: 400; }
.opt-state::after { content: ' ▾'; }
details[open] > summary.opt-summary .opt-state::after { content: ' ▴'; }
.opt-body { margin-top: 12px; }
.section-title { font-size: 13px; color: var(--text-sub); margin: 14px 2px 6px; }

/* 按钮 */
.btn {
  display: inline-block; border: none; border-radius: 8px;
  padding: 10px 16px; font-size: 14px; cursor: pointer; background: #eef2ff; color: var(--primary);
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: .5; }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; background: #fff;
}
.field input:focus { outline: none; border-color: var(--primary); }

/* 列表 */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .title { font-size: 15px; }
.list-item .meta { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

/* 点检/保养项目行 */
.item-row {
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-row .item-head { display: flex; align-items: center; justify-content: space-between; }
.item-row .item-name { font-size: 14px; font-weight: 500; }
.item-row .item-spec { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.badge {
  font-size: 10px; padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}
.badge.key { background: #fef3c7; color: #b45309; }
.badge.base { background: #e0e7ff; color: #3730a3; }
.badge.value { background: #dcfce7; color: #166534; }

/* 标记按钮组 */
.marks { display: flex; gap: 8px; margin-top: 8px; }
.mark-btn {
  flex: 1; padding: 8px 0; text-align: center; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; cursor: pointer; background: #fff; color: var(--text-sub);
}
.mark-btn.ok.active { background: var(--green); border-color: var(--green); color: #fff; }
.mark-btn.bad.active { background: var(--red); border-color: var(--red); color: #fff; }
.mark-btn.stop.active { background: var(--gray); border-color: var(--gray); color: #fff; }

/* 数值输入 */
.value-input {
  width: 100%; margin-top: 8px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px;
}
.value-input:focus { outline: none; border-color: var(--primary); }

/* 异常原因输入 */
.reason-input {
  width: 100%; margin-top: 8px; padding: 8px 10px; border: 1px solid #fca5a5;
  border-radius: 8px; font-size: 14px; font-family: inherit; line-height: 1.5;
  min-height: 54px; resize: vertical; background: #fff5f5; color: var(--text);
}
.reason-input:focus { outline: none; border-color: var(--red); background: #fff; }

/* 待提交高亮 */
.item-row.dirty { background: #fffbeb; border-radius: 8px; }

/* 底部提交栏（位于 Tab 栏上方） */
.submit-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(56px + env(safe-area-inset-bottom));
  width: 100%; max-width: 640px; padding: 8px 12px; box-sizing: border-box;
  background: rgba(245, 246, 250, .97); border-top: 1px solid var(--border);
  z-index: 15;
}

/* 分类 Tab / 日期 chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 16px; border: 1px solid var(--border);
  background: #fff; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip.warn { background: #fef2f2; color: var(--red); border-color: #fecaca; }

/* 设备选择 */
.eq-select {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.eq-select select {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
}

/* 统计卡片 */
.stat-row { display: flex; gap: 12px; }
.stat-box { flex: 1; background: var(--card); border-radius: 12px; padding: 16px; text-align: center; }
.stat-box .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-box .lbl { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.stat-box.green .num { color: var(--green); }
.stat-box.red .num { color: var(--red); }

/* 预警列表 */
.warn-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.warn-item:last-child { border-bottom: none; }
.warn-item .w-title { font-size: 14px; font-weight: 500; }
.warn-item .w-content { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.warn-item .w-time { font-size: 11px; color: var(--gray); margin-top: 4px; }

/* 首页快捷入口 */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quick-item {
  background: var(--card); border-radius: 12px; padding: 18px 8px; text-align: center;
  cursor: pointer; text-decoration: none; color: var(--text);
}
.quick-item .qi-ico { font-size: 26px; }
.quick-item .qi-label { font-size: 13px; margin-top: 6px; }
.quick-item .qi-badge {
  display: inline-block; margin-top: 4px; background: var(--red); color: #fff;
  font-size: 11px; border-radius: 10px; padding: 1px 8px;
}

/* 弹窗（默认隐藏，用 .open 控制显示，避免 hidden 属性与 display 冲突） */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 420px;
  max-height: 86vh; overflow-y: auto;
}
.modal h3 { font-size: 16px; margin-bottom: 14px; }

/* Toast（默认隐藏，用 .show 控制显示） */
.toast {
  display: none;
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,.75); color: #fff; padding: 12px 20px; border-radius: 8px;
  font-size: 14px; z-index: 60; max-width: 80%; text-align: center;
}
.toast.show { display: block; }

.empty { text-align: center; color: var(--gray); padding: 40px 0; font-size: 14px; }

/* 网格表格（报表异常清单/保养回看用） */
table.grid { width: 100%; border-collapse: collapse; font-size: 12px; }
table.grid th, table.grid td { border: 1px solid var(--border); padding: 4px; text-align: center; }
table.grid th { background: #f9fafb; }
