:root {
  --blue: #1a56db;
  --blue-dark: #143f9e;
  --blue-light: #eef2fd;
  --green: #12873f;
  --green-bg: #e6f6ec;
  --red: #d93026;
  --red-bg: #fdeceb;
  --orange: #d97706;
  --orange-bg: #fff4e5;
  --gray: #5a6472;
  --gray-2: #7b869a;
  --gray-3: #aeb6c4;
  --line: #e6eaf3;
  --bg: #f4f6fb;
  --white: #fff;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(26, 86, 219, 0.07);
  --shadow-lg: 0 12px 48px rgba(20, 25, 42, 0.16);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: #1f2430;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 布局 ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #14192a;
  color: #fff;
  padding: 24px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}

.logo-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-sub {
  font-size: 11px;
  color: #7b869a;
  margin-top: 4px;
}

.nav-item {
  padding: 13px 24px;
  font-size: 14px;
  color: #b7c0d0;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item.active {
  background: rgba(26, 86, 219, 0.18);
  color: #fff;
  border-left-color: var(--blue);
  font-weight: 500;
}

.nav-icon {
  width: 18px;
  text-align: center;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  padding: 14px 28px;
  box-shadow: 0 1px 4px rgba(20, 25, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--gray-2);
}

.content {
  padding: 24px 28px 60px;
  flex: 1;
}

.page { display: none; }
.page.active { display: block; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.card-title::before {
  content: '';
  width: 3px;
  height: 15px;
  background: var(--blue);
  border-radius: 2px;
}

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px 22px;
}

.form-item { display: flex; flex-direction: column; }

.form-item.full { grid-column: 1 / -1; }

label {
  font-size: 13px;
  color: var(--gray);
  margin-bottom: 7px;
  font-weight: 500;
}

label .req { color: var(--red); margin-left: 3px; }

input[type=text],
input[type=password],
input[type=date],
input[type=tel],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfcfe;
  color: #1f2430;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
  background: #fff;
}

textarea { resize: vertical; min-height: 72px; }

.field-hint {
  font-size: 12px;
  color: var(--gray-3);
  margin-top: 6px;
}

/* ---------- 按钮 ---------- */
.btn {
  padding: 9px 20px;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }

.btn-ghost { background: var(--blue-light); color: var(--blue); }
.btn-ghost:hover { background: #dfe7fc; }

.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fadcd9; }

.btn-plain { background: #fff; color: var(--gray); border: 1px solid var(--line); }
.btn-plain:hover { border-color: var(--gray-3); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 30px; font-size: 15px; }

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 统计 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-value.green { color: var(--green); }
.stat-value.orange { color: var(--orange); }
.stat-value.red { color: var(--red); }

.stat-label {
  font-size: 12.5px;
  color: var(--gray-2);
  margin-top: 5px;
}

/* ---------- 表格 ---------- */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar .search-box {
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  font-size: 13.5px;
  min-width: 1300px;   /* 证件列表 10 列，低于此宽度容器内横向滚动 */
}

/* 电话与公司名称不允许折行：列变窄时宁可行内滚动，也别把 11 位手机号或公司名拆成两段 */
tbody td[data-label="电话"],
tbody td[data-label="公司名称"] {
  white-space: nowrap;
}

thead th {
  background: #f7f9fd;
  color: var(--gray);
  font-weight: 600;
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-size: 12.5px;
}

tbody td {
  padding: 13px 10px;
  border-bottom: 1px solid #f0f2f7;
  vertical-align: middle;
  word-break: break-word;
}

/* 关键列不换行 */
tbody td.cell-name,
tbody td:nth-child(2),
tbody td:nth-child(5),
tbody td:nth-child(7),
tbody td:nth-child(8) {
  white-space: nowrap;
}

tbody td.cell-name {
  font-size: 14px;
}

tbody td:nth-child(2) {
  font-size: 13px;
}

/* 操作列按钮不换行 */
.cell-actions { white-space: nowrap; }

/* 有效期列：日期与徽章分两行
   用 data-label 定位而不是列序号，增删列时不会错位 */
tbody td[data-label="有效期至"] {
  white-space: nowrap;
}

tbody td[data-label="有效期至"] .badge-hint {
  display: block;
  margin-top: 4px;
  width: fit-content;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfe; }

.cell-name { font-weight: 600; }
.cell-code { font-family: Menlo, Consolas, monospace; font-size: 12.5px; color: var(--gray-2); }
.cell-actions { display: flex; gap: 8px; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.tag-valid { background: var(--green-bg); color: var(--green); }
.tag-expired { background: var(--red-bg); color: var(--red); }
.tag-suspended { background: var(--orange-bg); color: var(--orange); }
.tag-revoked { background: #eceff4; color: var(--gray); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-mask.show { display: flex; }

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  z-index: 1;
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--gray-3);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover { color: var(--red); }

.modal-body { padding: 22px; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: #fff;
  border-radius: 0 0 16px 16px;
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #14192a 0%, #1a56db 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-title {
  font-size: 21px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13px;
  color: var(--gray-2);
  text-align: center;
  margin-bottom: 26px;
}

.login-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

.login-card .form-item { margin-bottom: 16px; }

.login-card .btn { width: 100%; justify-content: center; }

/* ---------- 二维码 ---------- */
.qr-box {
  text-align: center;
  padding: 10px 0 4px;
}

.qr-img {
  width: 260px;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
  margin-bottom: 14px;
}

.qr-code-text {
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--gray);
  background: #f7f9fd;
  padding: 8px 14px;
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 6px;
}

.qr-tip {
  font-size: 12.5px;
  color: var(--gray-2);
  line-height: 1.7;
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-140%);
  background: #14192a;
  color: #fff;
  padding: 11px 22px;
  border-radius: 9px;
  font-size: 13.5px;
  z-index: 999;
  transition: transform .25s;
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-3);
  font-size: 13.5px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.badge-hint {
  display: inline-block;
  background: var(--orange-bg);
  color: var(--orange);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
}

/* 通道状态徽章 */
.channel-badge {
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eceff4;
  color: var(--gray-2);
  white-space: nowrap;
}

.channel-badge.ok { background: var(--green-bg); color: var(--green); }
.channel-badge.bad { background: var(--red-bg); color: var(--red); }

/* 核验结果网格 */
.verify-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px 22px;
}

.verify-item { min-width: 0; }

.vi-label {
  font-size: 12.5px;
  color: var(--gray-2);
  margin-bottom: 4px;
}

.vi-value {
  font-size: 15px;
  color: #1f2430;
  word-break: break-all;
}

.vi-mono {
  font-family: Menlo, Consolas, monospace;
  font-size: 13.5px;
}

/* ---------- 响应式：手机适配 ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 0;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .logo {
    padding: 4px 16px 4px 20px;
    margin-bottom: 0;
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, .08);
    flex-shrink: 0;
  }

  .logo-title { font-size: 14px; }
  .logo-sub { display: none; }

  .nav-item {
    padding: 10px 16px;
    font-size: 13px;
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }

  .nav-item.active {
    border-left: none;
    border-bottom-color: var(--blue);
  }

  .topbar { padding: 12px 16px; }
  .page-title { font-size: 16px; }
  .content { padding: 16px 14px 50px; }
  .card { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 25px; }
  .toolbar .search-box { max-width: none; }
  .modal { max-width: 100%; }
  .qr-img { width: 220px; height: 220px; }

  /* 表格转卡片：隐藏表头，每行渲染为独立卡片 */
  .table-wrap {
    border: none;
    overflow: visible;
    background: transparent;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead { display: none; }

  tbody tr {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    padding: 16px;
    position: relative;
  }

  tbody tr:hover { background: var(--white); }

  tbody td {
    border-bottom: none;
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    font-size: 13.5px;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--gray-2);
    font-size: 12.5px;
    flex-shrink: 0;
  }

  /* 姓名与状态放在卡片顶部 */
  tbody td[data-label="姓名"] {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 10px;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  tbody td[data-label="姓名"]::before { content: none; }

  tbody td[data-label="状态"] { margin-top: 10px; }

  /* 移动端徽章恢复行内 */
  tbody td[data-label="有效期至"] .badge-hint {
    display: inline-block;
    margin-top: 0;
  }

  tbody td[data-label="操作"] {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  tbody td[data-label="操作"]::before { content: none; }
  .cell-actions { width: 100%; }
  .cell-actions .btn { flex: 1; justify-content: center; }

  .cell-name { font-size: 16px; }
}

@media (max-width: 480px) {
  .btn { padding: 8px 14px; font-size: 13px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .user-name { display: none; }
}

/* ---------- 环境未就绪引导 ---------- */
.guide-box {
  background: var(--blue-light);
  border: 1px solid #d6e0fb;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
}

.guide-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 8px;
}

.guide-text {
  font-size: 12.5px;
  color: var(--gray);
  line-height: 1.75;
  margin-bottom: 12px;
  word-break: break-word;
}

.guide-btn {
  width: 100%;
  justify-content: center;
  font-size: 13px;
}

/* ---------- 批量导入 ---------- */
.import-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.import-tab {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: all .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.import-tab:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.import-tab.active {
  border-color: var(--blue);
  background: var(--blue-light);
  box-shadow: 0 0 0 2px rgba(26, 86, 219, .1);
}

.it-icon { font-size: 22px; line-height: 1.3; }
.it-title { font-size: 14px; font-weight: 500; color: var(--gray); }
.it-desc { font-size: 12px; color: var(--gray-2); }
.import-tab.active .it-title { color: var(--blue-dark); }

.drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: #fbfcfe;
}

.drop-zone:hover,
.drop-zone.drag {
  border-color: var(--blue);
  background: var(--blue-light);
}

.dz-icon { font-size: 34px; margin-bottom: 10px; }
.dz-title { font-size: 15px; color: var(--gray); margin-bottom: 6px; }
.dz-sub { font-size: 12.5px; color: var(--gray-2); }

.hint-box {
  background: #f7f9fd;
  border-radius: var(--radius-md);
  padding: 13px 15px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--gray-2);
  line-height: 1.8;
}
.hint-box b { color: var(--gray); }

.paste-area {
  width: 100%;
  min-height: 180px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  background: #fbfcfe;
}
.paste-area:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, .1);
  background: #fff;
}

.import-common {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.import-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

#previewBox { margin-top: 24px; }

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray);
  flex-wrap: wrap;
  gap: 10px;
}

.dl-toggle {
  font-size: 12.5px;
  color: var(--gray-2);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.import-result {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.8;
}
.import-result.ok { background: var(--green-bg); color: var(--green); }
.import-result.warn { background: var(--orange-bg); color: var(--orange); }
.ir-sub { font-size: 12.5px; margin-top: 6px; opacity: .9; }

tr.row-bad { background: #fff8f7; }
tr.row-bad td { color: var(--red); }

.ocr-progress { margin-top: 14px; }
.op-bar {
  height: 7px;
  background: #eef1f7;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.op-fill {
  height: 100%;
  width: 0;
  background: var(--blue);
  border-radius: 4px;
  transition: width .3s;
}
.op-text { font-size: 12.5px; color: var(--gray-2); }

@media (max-width: 860px) {
  .import-tabs { grid-template-columns: 1fr; }
  .import-actions .btn { flex: 1; justify-content: center; }
}

/* 导入预览：待补充行（橙色提示而非红色错误） */
tr.row-warn { background: #fffbf5; }
tr.row-warn td { color: #b26a00; }

/* ---------- 网页端降级码提示 ---------- */
.qr-degraded {
  background: #fff8ec;
  border: 1px solid #ffe4bc;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 14px;
  text-align: left;
}

.qd-title {
  font-size: 14px;
  font-weight: 600;
  color: #a86a00;
  margin-bottom: 8px;
}

.qd-text {
  font-size: 12.5px;
  color: #7a5a1a;
  line-height: 1.85;
}

.qd-text b {
  color: #8a5a00;
}

.qd-btn {
  width: 100%;
  justify-content: center;
  margin-top: 12px;
  font-size: 13px;
}

/* 证件照上传 */
.photo-picker { display: flex; gap: 16px; align-items: flex-start; }
.photo-preview {
  width: 96px; height: 128px; flex: none;
  border: 1px dashed var(--gray-3, #c9cdd4); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: var(--gray-1, #f5f6f7);
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder { color: var(--gray-3, #c9cdd4); font-size: 13px; text-align: center; line-height: 1.5; }
.photo-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
