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

:root {
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --danger: #ff4d4f;
  --danger-hover: #ff7875;
  --success: #52c41a;
  --warning: #faad14;
  --text: #1f1f1f;
  --text-secondary: #666;
  --text-muted: #999;
  --bg: #f5f5f5;
  --border: #e8e8e8;
  --card-bg: #fff;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

.hidden { display: none !important; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,0.04); color: var(--text); border-color: transparent; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 登录页 ===== */
#login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), #667eea);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.login-title { font-size: 22px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.login-subtitle { font-size: 14px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-secondary); }
.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color .2s;
}
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(22,119,255,.1); }

/* ===== 主界面布局 ===== */
#main-view { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; color: var(--primary); }
.header-user { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 14px; color: var(--text); }
.role-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #e6f4ff;
  color: var(--primary);
}
.role-badge.role-admin { background: #fff1f0; color: var(--danger); }

/* ===== 标签栏 ===== */
.tabs {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 99;
}
.tabs-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}
.tab {
  padding: 12px 20px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .2s;
  white-space: nowrap;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* ===== 内容区 ===== */
.content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== 页面头部 ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h2 { font-size: 18px; font-weight: 600; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.update-time { font-size: 12px; color: var(--text-muted); }

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-group label { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.filter-group select, .filter-group input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.filter-group select:focus, .filter-group input:focus { outline: none; border-color: var(--primary); }
.stats-bar { margin-left: auto; font-size: 13px; color: var(--text-secondary); }
.search-input, .filter-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.search-input { width: 200px; }

/* ===== 数据列表 ===== */
.data-list { display: flex; flex-direction: column; gap: 8px; }
.loading-placeholder { text-align: center; padding: 40px; color: var(--text-muted); }
.empty-placeholder { text-align: center; padding: 40px; color: var(--text-muted); }

/* ===== 预警卡片 ===== */
.alert-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.alert-card.level-紧急 { border-left-color: var(--danger); }
.alert-card.level-提醒 { border-left-color: var(--warning); }
.alert-card.level-关注 { border-left-color: var(--success); }
.alert-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.alert-station { font-size: 15px; font-weight: 600; }
.alert-level {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.alert-level.紧急 { background: #fff1f0; color: var(--danger); }
.alert-level.提醒 { background: #fffbe6; color: var(--warning); }
.alert-level.关注 { background: #f6ffed; color: var(--success); }
.alert-info { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--text-secondary); }
.alert-info-item { display: flex; align-items: center; gap: 4px; }
.alert-match-type {
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #f0f0f0;
  color: var(--text-secondary);
}
.alert-match-type.boundary { background: #e6f4ff; color: var(--primary); }
.alert-verify {
  margin-top: 6px; padding-top: 6px; border-top: 1px dashed #e8e8e8;
  font-size: 12px; color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.alert-map-link {
  display: inline-block; padding: 2px 10px; font-size: 12px;
  color: #1677ff; border: 1px solid #91caff; border-radius: 3px;
  text-decoration: none; background: #e6f4ff;
}
.alert-map-link:hover { background: #1677ff; color: #fff; }

/* ===== 公告卡片 ===== */
.blackout-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.blackout-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.blackout-district { font-size: 13px; color: var(--primary); font-weight: 500; }
.blackout-location { font-size: 14px; margin-bottom: 4px; }
.blackout-time { font-size: 12px; color: var(--text-muted); }

/* ===== 机房卡片 ===== */
.station-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.station-info { flex: 1; }
.station-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.station-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--text-secondary); }
.station-group {
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #f0f0f0;
}
.station-group.核心局房 { background: #fff1f0; color: var(--danger); }
.station-group.汇聚局房 { background: #fff7e6; color: var(--warning); }
.station-group.边缘局房 { background: #e6f4ff; color: var(--primary); }
.station-group.基站 { background: #f6ffed; color: var(--success); }
.station-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ===== 用户卡片 ===== */
.user-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.user-info { flex: 1; }
.user-display-name { font-size: 15px; font-weight: 600; }
.user-account { font-size: 13px; color: var(--text-secondary); }
.user-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.user-role-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}
.user-role-badge.admin { background: #fff1f0; color: var(--danger); }
.user-role-badge.operator { background: #e6f4ff; color: var(--primary); }
.user-role-badge.viewer { background: #f0f0f0; color: var(--text-secondary); }
.wx-status { font-size: 12px; }
.wx-status.bound { color: var(--success); }
.wx-status.unbound { color: var(--text-muted); }
.user-actions { display: flex; gap: 4px; flex-shrink: 0; flex-wrap: wrap; }

/* ===== 个人中心 ===== */
.profile-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 600px;
  margin-bottom: 16px;
}
.profile-row {
  display: flex;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.profile-row:last-child { border-bottom: none; }
.profile-label { width: 100px; color: var(--text-secondary); flex-shrink: 0; }
.profile-value { font-weight: 500; }
.profile-actions { display: flex; flex-direction: column; gap: 16px; max-width: 600px; }
.profile-action-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.profile-action-card h3 { font-size: 16px; margin-bottom: 8px; }
.token-display { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.token-code { font-size: 28px; font-weight: 700; letter-spacing: 4px; color: var(--primary); }
.token-date { font-size: 13px; color: var(--text-muted); }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-secondary); }
.form-group .required { color: var(--danger); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22,119,255,.1);
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.modal-card {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-sm { max-width: 400px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  border: none;
  background: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ===== 错误提示 ===== */
.error-msg {
  color: var(--danger);
  font-size: 13px;
  padding: 8px 12px;
  background: #fff1f0;
  border-radius: var(--radius);
  margin-top: 8px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 2000;
  animation: toast-in .3s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== 底部备案 ===== */
.footer, .footer-beian {
  text-align: center;
  padding: 16px;
  font-size: 13px;
}
.footer a, .footer-beian a {
  color: var(--text-muted);
  text-decoration: none;
}
.footer a:hover, .footer-beian a:hover { color: var(--primary); }
.footer-beian { color: rgba(255,255,255,0.8); margin-top: 24px; }
.footer-beian a { color: rgba(255,255,255,0.8); }

/* ===== 工具类 ===== */
.muted { color: var(--text-muted); font-size: 13px; }

/* ===== 徽标 ===== */
.badge {
  display: inline-block;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg);
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ===== 稽核页面 ===== */
.audit-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 14px;
}
.audit-summary .stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
}
.audit-summary .stat b { font-size: 16px; }
.audit-result-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
}
.audit-result-badge.normal { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.audit-result-badge.full    { background: #e6f4ff; color: #1677ff; border: 1px solid #91caff; }
.audit-result-badge.partial { background: #fffbe6; color: #faad14; border: 1px solid #ffe58f; }
.audit-result-badge.nomatch { background: #fff1f0; color: #ff4d4f; border: 1px solid #ffa39e; }
.audit-result-badge.nostation { background: #f0f0f0; color: #888; border: 1px solid #d9d9d9; }
.audit-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  background: #fff;
}
.audit-card .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.audit-card .row1 .name { font-weight: 600; }
.audit-card .meta { font-size: 13px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 12px; }
.alert-card .detail { font-size: 12px; color: var(--text-secondary); }

/* 稽核进度条 */
.audit-progress-wrap { padding: 30px 20px; text-align: center; }
.audit-progress-info { font-size: 14px; color: var(--text-secondary); margin-bottom: 10px; }
.audit-progress-bar {
  width: 100%; max-width: 400px; height: 20px; margin: 0 auto;
  background: #f0f0f0; border-radius: 10px; overflow: hidden;
}
.audit-progress-fill {
  height: 100%; background: linear-gradient(90deg, #1677ff, #52c41a);
  border-radius: 10px; transition: width 0.3s;
}

/* 稽核匹配方式/记录数标签 */
.audit-match-badge {
  font-size: 11px; padding: 1px 6px; border-radius: 3px;
  background: #e6f4ff; color: #1677ff; border: 1px solid #91caff;
}
.audit-count-badge {
  font-size: 11px; padding: 1px 6px; border-radius: 3px;
  background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .header-inner, .tabs-inner, .content { padding: 0 12px; }
  .content { padding-top: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; }
  .search-input { width: 100%; }
  .station-card, .user-card { flex-direction: column; align-items: flex-start; }
  .station-actions, .user-actions { width: 100%; }
  .form-row { flex-direction: column; }
}

/* ===== 批量导入 ===== */
.import-steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 16px;
}
.import-step {
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
}
.step-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.import-result {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.result-summary {
  padding: 12px 16px;
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--success);
  font-weight: 500;
}
.result-summary.has-fail {
  background: #fffbe6;
  border-color: #ffe58f;
  color: var(--warning);
}
.result-list-wrapper { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.result-list-header { padding: 8px 12px; background: var(--bg); font-size: 13px; color: var(--text-secondary); border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.result-list { display: flex; flex-direction: column; }
.result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.result-item:last-child { border-bottom: none; }
.result-item .row-num { color: var(--text-muted); width: 40px; flex-shrink: 0; }
.result-item .name { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-item .status { font-size: 12px; padding: 1px 6px; border-radius: 3px; flex-shrink: 0; }
.result-item .status.ok { background: #f6ffed; color: var(--success); }
.result-item .status.fail { background: #fff1f0; color: var(--danger); }
.result-item .status.skip { background: #f0f0f0; color: var(--text-muted); }
.result-item .geo-info { font-size: 12px; color: var(--text-muted); flex-shrink: 0; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-progress { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 20px; }
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
