/* ===== 全局 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #07c160;        /* 企微绿 */
  --primary-dark: #06ad56;
  --danger: #e64340;
  --warn: #fa9d3b;
  --text: #1f2329;
  --text-light: #8a8f99;
  --border: #e5e6eb;
  --bg: #f5f6f7;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(31, 35, 41, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 顶部导航 ===== */
.topbar {
  background: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .logo { font-size: 22px; }
.nav { display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
}
.nav a:hover { background: #f0f9f4; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.topbar-right { font-size: 13px; color: var(--text-light); white-space: nowrap; }
.topbar-right a { margin-left: 12px; }

/* ===== 布局 ===== */
.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

/* ===== 提示消息 ===== */
.flash {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.flash.success { background: #e8f9ef; color: #0a7c42; border: 1px solid #b7ebc6; }
.flash.error   { background: #fdecec; color: #c23531; border: 1px solid #f8c4c3; }
.flash.warn    { background: #fff6e8; color: #b06a12; border: 1px solid #fcd9a4; }
.flash.info    { background: #eef4ff; color: #2b5cb8; border: 1px solid #c4d8fb; }

/* ===== 统计卡片 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  text-align: center;
}
.stat-card .num { font-size: 34px; font-weight: 700; color: var(--primary-dark); }
.stat-card .label { color: var(--text-light); font-size: 14px; margin-top: 4px; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-light); font-weight: 600; background: #fafbfc; }
tr:hover td { background: #fafdfb; }
td.wrap { white-space: normal; min-width: 120px; }
.empty { text-align: center; color: var(--text-light); padding: 36px 0; }

/* ===== 徽章/状态 ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
}
.badge.green { background: #e8f9ef; color: #0a7c42; }
.badge.gray  { background: #f0f1f2; color: #8a8f99; }
.badge.red   { background: #fdecec; color: #c23531; }
.badge.blue  { background: #eef4ff; color: #2b5cb8; }

/* ===== 按钮 ===== */
.btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.btn:hover { text-decoration: none; border-color: var(--primary); color: var(--primary-dark); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f3c1c0; }
.btn.danger:hover { background: #fdecec; }
.btn.sm { padding: 4px 12px; font-size: 13px; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.form-group .hint { font-weight: 400; color: var(--text-light); font-size: 12px; margin-left: 6px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, .12);
}
textarea { min-height: 70px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; }

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(135deg, #e8f9ef 0%, #f5f6f7 60%);
}
.login-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(31, 35, 41, .12);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--text-light); font-size: 13px; margin-bottom: 26px; }
.login-card .btn { width: 100%; padding: 11px; font-size: 15px; }

/* ===== 二维码展示 ===== */
.qr-box {
  text-align: center;
  padding: 16px;
}
.qr-box img {
  width: 240px;
  height: 240px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
}
.qr-placeholder {
  width: 240px;
  height: 240px;
  margin: 0 auto;
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  gap: 10px;
}
.detail-grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--text-light); }
.kv dd { word-break: break-all; }

/* ===== 趋势柱状图（纯CSS） ===== */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 140px;
  padding-top: 10px;
  border-bottom: 1px solid var(--border);
}
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart .bar {
  width: 70%;
  background: linear-gradient(180deg, #34d399, var(--primary));
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  position: relative;
}
.chart .bar:hover { background: var(--primary-dark); }
.chart .bar .tip {
  display: none;
  position: absolute;
  bottom: 105%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.chart .bar:hover .tip { display: block; }
.chart-labels { display: flex; gap: 3px; margin-top: 6px; }
.chart-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--text-light); }

/* ===== 日志 ===== */
.log-view {
  background: #1e1e2e;
  color: #d4e8d4;
  border-radius: 8px;
  padding: 14px;
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.7;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== 打印页（A4） ===== */
.print-page { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-page, .print-page * { visibility: visible; }
  .print-page { display: block; position: absolute; left: 0; top: 0; width: 100%; }
  .no-print { display: none !important; }
}
.print-sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 25mm 20mm;
  text-align: center;
  box-sizing: border-box;
}
.print-sheet h1 { font-size: 28px; margin-bottom: 8px; }
.print-sheet .sub { color: #666; font-size: 15px; margin-bottom: 30px; }
.print-sheet img { width: 120mm; height: 120mm; }
.print-sheet .tip { margin-top: 26px; font-size: 15px; color: #444; line-height: 2; }
.print-sheet .footer { margin-top: 40px; font-size: 13px; color: #999; }

/* ===== 手机端通用增强 ===== */
.cell-sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.cell-nowrap { white-space: nowrap; }

/* 宽表格在手机端转「卡片式」（配合 td[data-label]） */
@media (max-width: 720px) {
  table.cards-table thead { display: none; }
  table.cards-table,
  table.cards-table tbody,
  table.cards-table tr,
  table.cards-table td { display: block; width: 100%; }
  table.cards-table tr {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 6px 12px;
    box-shadow: 0 1px 4px rgba(31,35,41,.05);
  }
  table.cards-table tr:hover td { background: transparent; }
  table.cards-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    border-bottom: 1px dashed var(--border);
    padding: 9px 2px;
    white-space: normal;
    text-align: right;
  }
  table.cards-table td:last-child { border-bottom: none; }
  table.cards-table td::before {
    content: attr(data-label);
    color: var(--text-light);
    font-size: 13px;
    flex: 0 0 auto;
    text-align: left;
  }
  /* 名称类单元格靠左纵向排列，更像卡片主信息 */
  table.cards-table td[data-label="合作商"] { flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
  table.cards-table td[data-label="操作"] .btn { padding: 8px 16px; }
}

/* ===== 顶栏：手机/平板/横屏窄窗口下换两行，导航可横向滑动 ===== */
@media (max-width: 920px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 9px 12px; gap: 6px 10px; }
  .brand { font-size: 16px; }
  .topbar-right { margin-left: auto; font-size: 12px; white-space: nowrap; }
  .topbar-right a { margin-left: 8px; }
  .nav {
    order: 3; width: 100%; flex: 0 0 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap; padding-bottom: 2px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav { scrollbar-width: none; }
  .nav a { padding: 7px 13px; font-size: 14px; flex: 0 0 auto; }
}

/* ===== 响应式（手机/平板） ===== */
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
  .brand { font-size: 16px; }
  .topbar-right { margin-left: auto; font-size: 12px; }
  .topbar-right a { margin-left: 8px; }
  .nav { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 7px 13px; font-size: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-grid .stat-card:last-child { grid-column: 1 / -1; }
  .stat-card { padding: 16px 10px; }
  .stat-card .num { font-size: 28px; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .container { margin: 12px auto; padding: 0 12px; }
  .card { padding: 14px; border-radius: 10px; }
  .page-title { font-size: 18px; }
  .qr-box img, .qr-placeholder { width: 190px; height: 190px; }
  th, td { padding: 9px 8px; }
  /* 表单更适合手指点按 */
  input[type=text], input[type=password], input[type=number],
  input[type=search], input[type=email], textarea, select {
    font-size: 16px;            /* >=16px 防止 iOS 聚焦自动放大 */
    padding: 11px 12px;
  }
  .btn { padding: 10px 18px; }
  .btn.sm { padding: 7px 14px; font-size: 13px; }
  .form-actions { gap: 8px; }
  .form-actions .btn { flex: 1; text-align: center; }
  .kv { grid-template-columns: 84px 1fr; }
  .flash { font-size: 13px; }
  .chart { height: 110px; }
}

/* 窄屏手机：统计卡单列；更新进度弹窗变底部抽屉 */
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat-grid .stat-card:last-child { grid-column: auto; }
  .modal-mask { align-items: flex-end !important; padding: 0 !important; }
  .modal-mask .card {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
    margin-bottom: 0;
    animation: sheetUp .22s ease;
  }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
}

/* ===== 备案页脚 ===== */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 20px;
  text-align: center;
  padding: 18px 10px 24px;
  font-size: 13px;
  color: #999;
}
.site-footer a {
  color: #999;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.site-footer a:hover {
  color: #666;
  text-decoration: underline;
}
.site-footer a.gongan img {
  width: 14px;
  height: 16px;
  margin-right: 4px;
  vertical-align: middle;
}

/* ===== 首页最近扫码·简洁列表 ===== */
.scan-quick-list { list-style:none; margin:10px 0 0; padding:0; }
.scan-quick-list li { border-bottom:1px solid var(--border,#eee); }
.scan-quick-list li:last-child { border-bottom:none; }
.scan-quick-item {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:11px 4px; text-decoration:none; color:inherit;
}
a.scan-quick-item { -webkit-tap-highlight-color:transparent; }
a.scan-quick-item:active { background:#f5f7f6; }
.scan-quick-main { display:flex; flex-direction:column; gap:3px; min-width:0; }
.scan-quick-name { font-weight:600; font-size:15px; color:var(--text,#222); }
a.scan-quick-item .scan-quick-name { color:var(--primary,#07c160); }
.scan-quick-meta { font-size:12.5px; color:var(--text-light,#999); }
.scan-quick-item.is-static { cursor:default; }

/* ===== 扫码记录筛选栏 / 分页 ===== */
.filter-bar { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.filter-bar .btn { white-space:nowrap; }
.pagination {
  display:flex; align-items:center; justify-content:center; gap:14px;
  margin-top:16px;
}
.pagination .page-info { font-size:14px; color:var(--text-light,#888); }
@media (max-width:560px) {
  .filter-bar select { flex:1 1 calc(50% - 5px); min-width:0; }
  .filter-bar .btn { flex:1 1 auto; }
}
