/* 客户分级结果可视化平台 —— 浅色仪表盘风格 */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1b2434;
  --muted: #5c6b82;
  --border: #e3e9f3;
  --accent: #2f6bff;
  --accent-dark: #1e50cc;
  --tier-1: #6d4aff;
  --tier-2: #2f6bff;
  --tier-3: #64748b;
  --tier-4: #94a3b8;
  --national-fg: #92400e;
  --national-bg: #fef3c7;
  --local-fg: #1d4ed8;
  --local-bg: #dbeafe;
  --danger: #c62828;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(27, 36, 52, 0.08), 0 4px 16px rgba(27, 36, 52, 0.05);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px; top: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus { left: 12px; }

/* 焦点样式：保证键盘可见性 */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ===== 头部 ===== */
.site-header {
  background: linear-gradient(135deg, #24477f 0%, #2f6bff 100%);
  color: #fff;
  padding: 26px 0;
  margin-bottom: 24px;
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
.brand {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.tagline {
  margin: 4px 0 0;
  opacity: 0.9;
  font-size: 14px;
}
.status-pills {
  display: flex;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
}
.pill .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
}
.pill.is-ok .dot { background: #4ade80; }

/* ===== 卡片 ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title {
  margin: 26px 0 12px;
  font-size: 18px;
}
.note {
  color: var(--muted);
  font-size: 13px;
  margin: 12px 0 0;
}

/* ===== 上传区 ===== */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
  background: #fafbfe;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.is-drag {
  border-color: var(--accent);
  background: #eef3ff;
}
.dz-title { margin: 0 0 6px; font-weight: 600; }
.dz-hint { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.dz-status { margin: 0; font-size: 13px; color: var(--accent-dark); font-weight: 600; }

/* ===== 标签页 ===== */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab {
  appearance: none;
  border: none;
  background: none;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--accent-dark); }
.tab.is-active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}
.panel-head { margin-bottom: 16px; }
.panel-head h2 { margin: 0 0 6px; font-size: 21px; }
.panel-desc { margin: 0; color: var(--muted); }

/* ===== 规则配置 ===== */
.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.rule-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px 10px;
  margin: 0;
}
.rule-box legend {
  font-weight: 700;
  padding: 0 6px;
  color: var(--accent-dark);
}
.rule-box label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 4px;
}
.rule-box input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}
.rule-hint {
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0 2px;
}
.form-error {
  color: var(--danger);
  font-size: 14px;
  margin: 10px 0 0;
}
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ===== 按钮 ===== */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-ghost { background: transparent; }

/* ===== 汇总卡片 ===== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.sum-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.sum-card .sum-label {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 6px;
}
.sum-card .sum-value {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
  word-break: break-all;
}
.sum-card .sum-sub {
  color: var(--muted);
  font-size: 12.5px;
  margin: 6px 0 0;
}
.sum-card.tier-1 { border-top: 4px solid var(--tier-1); }
.sum-card.tier-2 { border-top: 4px solid var(--tier-2); }
.sum-card.tier-3 { border-top: 4px solid var(--tier-3); }
.sum-card.tier-4 { border-top: 4px solid var(--tier-4); }
.sum-card.tier-all { border-top: 4px solid var(--accent); }

/* ===== 图表（CSS 条形图，无第三方依赖） ===== */
.chart { display: grid; gap: 14px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 150px) 1fr auto;
  gap: 12px;
  align-items: center;
}
.bar-name { font-weight: 600; font-size: 14px; }
.bar-track {
  background: #eef1f7;
  border-radius: 999px;
  height: 18px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  min-width: 2px;
}
.bar-fill.tier-1 { background: var(--tier-1); }
.bar-fill.tier-2 { background: var(--tier-2); }
.bar-fill.tier-3 { background: var(--tier-3); }
.bar-fill.tier-4 { background: var(--tier-4); }
.bar-fill.national { background: var(--tier-2); }
.bar-fill.local { background: var(--tier-3); }
.bar-value { font-size: 13px; color: var(--muted); white-space: nowrap; }
.chart-sub {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

/* ===== 表格工具条 ===== */
.table-controls {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}
.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.field-inline label, .field-label { color: var(--muted); font-size: 13px; }
.field-inline input, .field-inline select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}
.field-inline input[type="search"] { width: 220px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}
.chip[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.result-count { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }

/* ===== 数据表 ===== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: #fff;
}
thead th {
  background: #f2f5fb;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody td {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tbody tr:hover { background: #f7f9ff; }
.th-btn {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.th-btn:hover { color: var(--accent-dark); text-decoration: underline; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.national { background: var(--national-bg); color: var(--national-fg); }
.badge.local { background: var(--local-bg); color: var(--local-fg); }
.badge.tier-1 { background: #ede9fe; color: #5b21b6; }
.badge.tier-2 { background: #dbeafe; color: #1e40af; }
.badge.tier-3 { background: #e2e8f0; color: #334155; }
.badge.tier-4 { background: #f1f5f9; color: #475569; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }

.expand-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  width: 26px; height: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--accent-dark);
  font-size: 13px;
}
.expand-btn:hover { border-color: var(--accent); }
.detail-cell {
  background: #f8faff;
  padding: 12px 16px !important;
  white-space: normal;
}
.detail-table {
  width: 100%;
  font-size: 12.5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.detail-table th { background: #eef2fa; position: static; }
.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 32px 0;
}

/* ===== 分页 ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.page-info { color: var(--muted); font-size: 13px; }
.page-size { color: var(--muted); font-size: 13px; margin-left: auto; }
.page-size select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ===== 其他 ===== */
.site-footer {
  padding: 24px 0 36px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 720px) {
  .brand { font-size: 21px; }
  .tab { font-size: 15px; padding: 10px 14px; }
  .field-inline input[type="search"] { width: 100%; }
  .page-size { margin-left: 0; }
}

/* ============================================================
   多页面拆分新增：导航 / 三态 / 表单 / 公告 / 徽标
   ============================================================ */

/* ===== 统一导航 ===== */
.brand-link {
  color: inherit;
  text-decoration: none;
}
.brand-link:hover { text-decoration: underline; }
.main-nav {
  background: rgba(255, 255, 255, 0.12);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  margin-top: 18px;
}
.nav-inner {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-link {
  color: #e8eefc;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 600;
  padding: 11px 18px;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.nav-link.is-active {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border-bottom-color: #ffd166;
}

/* ===== 加载 / 空数据 / 异常 三态 ===== */
.state-box {
  text-align: center;
  padding: 42px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: #fafbfe;
  color: var(--muted);
}
.state-title { font-size: 16px; font-weight: 600; color: var(--text); margin: 10px 0 4px; }
.state-desc { margin: 0; font-size: 13.5px; }
.state-actions { margin-top: 14px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.state-icon { font-size: 30px; }
.state-error { border-color: #f3c2c2; background: #fdf3f3; }
.spinner {
  width: 30px; height: 30px;
  margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  html { scroll-behavior: auto; }
}

/* ===== 提示条 ===== */
.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.banner-info { background: #eef3ff; border: 1px solid #cdd9f8; color: #1e3a8a; }
.banner-warn { background: #fff8e6; border: 1px solid #f2dfa8; color: #92400e; }
.banner-error { background: #fdf3f3; border: 1px solid #f3c2c2; color: #b91c1c; }
.banner strong { display: block; margin-bottom: 2px; }

/* ===== 表单（规则） ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.form-field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  font-family: inherit;
}
.form-field textarea { min-height: 84px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

/* ===== 徽标补充 ===== */
.badge.tier-auto { background: #e0f2fe; color: #075985; }
.badge.tier-manual { background: #fde68a; color: #92400e; }
.badge.plain { background: #eef1f7; color: var(--muted); }
.badge.on { background: #dcfce7; color: #166534; }
.badge.off { background: #f1f5f9; color: #64748b; }

/* ===== 表格行内操作按钮 ===== */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-mini {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--accent-dark);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-mini:hover { border-color: var(--accent); }
.btn-mini.danger { color: var(--danger); }
.btn-mini.danger:hover { border-color: var(--danger); }
.btn-mini[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== 公告（主页） ===== */
.notice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}
.notice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.notice-card h3 { margin: 0 0 10px; font-size: 16px; }
.notice-tag {
  display: inline-block;
  background: #eef3ff;
  color: var(--accent-dark);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  margin-right: 8px;
}
.notice-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fffdf5;
}
.notice-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.notice-item-title { font-weight: 700; margin: 0; }
.notice-item-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.notice-item-body { margin: 6px 0 0; color: var(--text); font-size: 13.5px; white-space: pre-wrap; }

@media (max-width: 720px) {
  .nav-link { padding: 9px 12px; font-size: 13.5px; }
  .notice-grid { grid-template-columns: 1fr; }
}
