/* ============================================================
   工分查询端 · 设计系统  v3.0
   深色导航 + 浅色数据台；数字等宽对齐、表头吸顶、宽表首列吸左
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  /* 中性色 */
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --surface-3: #f5f7fc;
  --line: #e4e8f1;
  --line-soft: #eaeef6;
  --row-alt: #f5f8fd;
  --row-hover: #eaf2ff;

  --ink-900: #0c1526;
  --ink-800: #16233c;
  --ink-700: #344054;
  --ink-500: #667085;
  --ink-400: #98a2b3;
  --ink-300: #c6cdd9;

  /* 品牌 */
  --brand: #2f6bf6;
  --brand-600: #1e56dd;
  --brand-700: #1746b8;
  --brand-100: #dbe7ff;
  --brand-050: #eef4ff;

  /* 语义色 */
  --red-600: #dc2626;
  --red-500: #ef4444;
  --red-050: #fef2f2;
  --amber-600: #b45309;
  --amber-500: #e08a00;
  --amber-050: #fff8e8;
  --teal-600: #0d8f86;
  --teal-050: #e7f7f5;
  --purple-600: #7c3aed;
  --purple-050: #f3edff;
  --green-600: #15803d;
  --green-500: #16a34a;
  --green-050: #eafaf0;

  /* 侧栏 */
  --side-1: #0e1730;
  --side-2: #172747;
  --side-line: rgba(255, 255, 255, .075);
  --side-ink: #a9b8d4;
  --side-ink-2: #7186ab;
  --side-active: #4d8bff;

  /* 形状 */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --sh-1: 0 1px 2px rgba(16, 32, 66, .05);
  --sh-2: 0 2px 8px rgba(16, 32, 66, .06), 0 1px 2px rgba(16, 32, 66, .04);
  --sh-3: 0 10px 28px rgba(16, 32, 66, .10), 0 2px 6px rgba(16, 32, 66, .05);
  --sh-4: 0 24px 60px rgba(9, 18, 40, .28);

  --f-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --f-mono: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, Menlo, monospace;

  --side-w: 252px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-900);
  font-family: var(--f-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
code {
  font-family: var(--f-mono);
  font-size: .92em;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  padding: 1px 5px;
}

/* 滚动条 */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cdd5e3; border: 3px solid transparent; background-clip: padding-box; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #aab6ca; background-clip: padding-box; }

/* ---------- 布局骨架 ---------- */
.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ============================================================
   侧边栏
   ============================================================ */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(720px 320px at -10% -5%, rgba(77, 139, 255, .20), transparent 60%),
    linear-gradient(170deg, var(--side-2) 0%, var(--side-1) 60%);
  color: var(--side-ink);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--side-line);
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: #fff;
  background: linear-gradient(140deg, #5b96ff 0%, #2f6bf6 55%, #1b46c4 100%);
  box-shadow: 0 6px 16px rgba(47, 107, 246, .42), inset 0 1px 0 rgba(255, 255, 255, .35);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.brand-text strong { color: #fff; font-size: 15.5px; letter-spacing: .2px; }
.brand-text span { color: var(--side-ink-2); font-size: 11.5px; letter-spacing: .3px; }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 8px;
}
.nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); background-clip: padding-box; }

.nav-group {
  padding: 16px 10px 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: var(--side-ink-2);
  text-transform: uppercase;
}
.nav-group:first-child { padding-top: 6px; }

.nav-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 3px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--side-ink);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.nav-item > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.nav-item .ni-ico {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #c3d3ef;
  background: rgba(255, 255, 255, .09);
  transition: background .16s ease, color .16s ease;
}

.nav-item .ni-count {
  flex: none;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--side-ink-2);
  background: rgba(255, 255, 255, .06);
  border-radius: 20px;
  padding: 1px 8px;
}

.nav-item.active {
  background: linear-gradient(100deg, rgba(77, 139, 255, .26), rgba(77, 139, 255, .08));
  color: #fff;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--side-active);
  box-shadow: 0 0 12px rgba(77, 139, 255, .8);
}
.nav-item.active .ni-ico {
  color: #fff;
  background: linear-gradient(140deg, #5b96ff, #2f6bf6);
  box-shadow: 0 4px 10px rgba(47, 107, 246, .45);
}
.nav-item.active .ni-count { color: #dbe7ff; background: rgba(255, 255, 255, .14); }

.sidebar-foot {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--side-line);
  background: rgba(0, 0, 0, .16);
}

.ver {
  margin-top: 12px;
  font-size: 11px;
  color: var(--side-ink-2);
  text-align: center;
  letter-spacing: .4px;
}

.foot-row { display: flex; gap: 8px; margin-top: 8px; }
.foot-row .btn { flex: 1; }

/* 数据状态胶囊（侧栏内） */
.src-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  margin-bottom: 10px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  color: #c8d6ee;
  font-size: 11.5px;
  line-height: 1.5;
  cursor: default;
}
.src-chip .dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--green-500);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .18);
}
.src-chip.stale { background: rgba(224, 138, 0, .16); border-color: rgba(224, 138, 0, .34); color: #ffd79a; }
.src-chip.stale .dot { background: #ffb020; box-shadow: 0 0 0 3px rgba(255, 176, 32, .2); }
.src-chip.very-stale { background: rgba(220, 38, 38, .18); border-color: rgba(220, 38, 38, .38); color: #ffb4b4; }
.src-chip.very-stale .dot { background: var(--red-500); box-shadow: 0 0 0 3px rgba(239, 68, 68, .2); }
.src-chip.imported .dot { background: var(--brand); box-shadow: 0 0 0 3px rgba(47, 107, 246, .2); }

/* ============================================================
   主区
   ============================================================ */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 26px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-left { flex: 1; min-width: 0; }
.topbar-left h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--ink-900);
  display: flex;
  align-items: center;
  gap: 9px;
}
.topbar-left h1::before {
  content: '';
  width: 4px;
  height: 17px;
  border-radius: 3px;
  background: linear-gradient(180deg, #5b96ff, var(--brand-600));
  flex: none;
}
.topbar-left p {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }

/* ---------- 管理模式：默认只读，登录后才出现上传/导出 ---------- */
#btnImport { display: none; }
body.is-admin #btnImport { display: inline-flex; }

/* 「使用说明」也归管理员：内容含服务器命令与全表口径 */
#btnHelp { display: none; }
body.is-admin #btnHelp { display: inline-flex; }

/* 权限不足被拦回时的轻提示条 */
.gf-notice {
  display: none;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff8e8;
  border: 1px solid #ffe1a6;
  color: #8a5a00;
  font-size: 13px;
  line-height: 1.6;
}
.gf-notice.show { display: block; }

.admin-badge {
  display: none;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: 20px;
  background: var(--green-050);
  border: 1px solid #c3ecd3;
  color: var(--green-600);
  font-size: 12px;
  font-weight: 600;
}
.admin-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-500);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .18);
}
body.is-admin .admin-badge { display: inline-flex; }

.admin-ok {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 16px;
  border-radius: var(--r-md);
  background: var(--green-050);
  border: 1px solid #c3ecd3;
}
.admin-ok .ao-ico {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, #34d27b, var(--green-600));
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(22, 163, 74, .3);
}
.admin-ok b { font-size: 14px; color: var(--green-600); }
.admin-ok p { margin-top: 3px; font-size: 12.5px; color: var(--ink-500); }

.content { padding: 22px 26px 40px; min-width: 0; }

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .06s ease;
}
.btn:hover { background: var(--surface-3); border-color: #d3dae7; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #3d78ff, var(--brand-600));
  border-color: var(--brand-600);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(47, 107, 246, .3);
}
.btn-primary:hover { background: linear-gradient(180deg, #4d85ff, var(--brand)); border-color: var(--brand); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-500); }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--line); color: var(--ink-700); }

.btn-sm { height: 31px; padding: 0 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* 侧栏内的 ghost 按钮配色 */
.sidebar-foot .btn-ghost { color: #a9b8d4; border-color: rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .04); }
.sidebar-foot .btn-ghost:hover { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .18); }

/* ============================================================
   面板 / 卡片
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  overflow: hidden;
  margin-bottom: 18px;
}
.panel:last-child { margin-bottom: 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fdfdff, var(--surface-2));
  flex-wrap: wrap;
}
.panel-head h3 {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -.1px;
  color: var(--ink-900);
}
.ph-sub { margin-top: 2px; font-size: 12px; color: var(--ink-500); }
.ph-sub b { color: var(--ink-800); font-variant-numeric: tabular-nums; }
.ph-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.panel-body { padding: 16px 18px 18px; }

/* ============================================================
   条件输入区（黄底 = 条件格，与主簿一致）
   ============================================================ */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px 16px;
  align-items: end;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--ink-500);
  display: flex;
  align-items: center;
  gap: 5px;
}
.field label::before {
  content: '';
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: #f2c14e;
  flex: none;
}

.field input[type="text"],
.field input[type="date"],
.field input[type="password"],
.field select {
  height: 38px;
  padding: 0 11px;
  border: 1px solid #e8dcb8;
  border-radius: var(--r-sm);
  background: #fffdf4;              /* 黄底：与主簿黄格同义 */
  color: var(--ink-900);
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  width: 100%;
  min-width: 0;
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%23667085' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
  background-color: #fffdf4;
}
.field input::placeholder { color: #b9b08e; }
.field input:hover, .field select:hover { border-color: #ddc98e; }
.field input:focus, .field select:focus {
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 246, .14);
}

.filter-actions { display: flex; align-items: flex-end; }

/* 已选条件 chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 11px;
  border-radius: 20px;
  background: var(--brand-050);
  border: 1px solid var(--brand-100);
  color: var(--brand-700);
  font-size: 12px;
  font-weight: 500;
}
.chip b { font-weight: 600; color: var(--ink-700); }
.chip button {
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(47, 107, 246, .16);
  color: var(--brand-700);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background .15s ease;
}
.chip button:hover { background: var(--brand); color: #fff; }

/* ============================================================
   指标卡
   ============================================================ */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.panel-body > .metrics { margin-bottom: 0; }

.metric {
  position: relative;
  padding: 15px 17px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  overflow: hidden;
  transition: box-shadow .18s ease, transform .18s ease;
}
.metric::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent, var(--brand));
}
.metric::after {
  content: '';
  position: absolute;
  right: -34px;
  top: -34px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--accent, var(--brand));
  opacity: .055;
}
.metric:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }

.m-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-500);
  letter-spacing: .2px;
  margin-bottom: 6px;
}
.m-value {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.9px;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.m-value small { font-size: 12.5px; font-weight: 600; color: var(--ink-400); margin-left: 4px; letter-spacing: 0; }
.m-sub { margin-top: 5px; font-size: 11.5px; color: var(--ink-400); }

.tone-blue { --accent: var(--brand); }
.tone-amber { --accent: var(--amber-500); }
.tone-teal { --accent: var(--teal-600); }
.tone-purple { --accent: var(--purple-600); }
.tone-red { --accent: var(--red-600); }
.tone-green { --accent: var(--green-500); }

.metric[data-goto] { cursor: pointer; }
.metric[data-goto]:hover { border-color: var(--brand-100); }

/* ============================================================
   表格
   ============================================================ */
.table-wrap {
  max-height: 72vh;
  overflow: auto;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}

table.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.8px;
}

table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 10px 11px;
  background: #f7f9fd;
  color: var(--ink-700);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line-soft);
  cursor: pointer;
  user-select: none;
  transition: background .14s ease, color .14s ease;
}
table.grid thead th:hover { background: #eef3fc; color: var(--brand-700); }
table.grid thead th:last-child { border-right: 0; }
table.grid thead th.num { text-align: right; }
table.grid thead th.sorted { background: var(--brand-050); color: var(--brand-700); }
table.grid thead th .arrow { font-size: 9px; color: var(--brand); }

table.grid tbody td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid #f6f8fc;
  color: var(--ink-800);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.grid tbody td:last-child { border-right: 0; }
table.grid tbody td.num { text-align: right; }
table.grid tbody td.mono { font-family: var(--f-mono); font-size: 12.2px; letter-spacing: -.2px; }
table.grid tbody td.neg { color: var(--red-600); font-weight: 700; }

table.grid tbody tr { transition: background .12s ease; }
table.grid tbody tr:hover td { background: var(--row-hover); }
table.grid tbody tr:nth-child(even) td { background: var(--row-alt); }
table.grid tbody tr:nth-child(even):hover td { background: var(--row-hover); }

/* 末列占位：把多余宽度全吃掉，避免列少时被拉得像散架 */
table.grid th.grid-spacer, table.grid td.grid-spacer {
  width: 100%;
  min-width: 0;
  padding: 0;
  border-right: 0;
  border-bottom-color: transparent;
}
table.grid thead th.grid-spacer { background: #f7f9fd; cursor: default; }
table.grid thead th.grid-spacer:hover { background: #f7f9fd; }

/* 姓名单元格 */
table.grid td.name-cell { font-weight: 600; color: var(--ink-900); }

/* 名次徽标 */
.rank {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--ink-500);
}
.rank.r1 { background: linear-gradient(140deg, #ffd77a, #d9931f); color: #6d4200; }
.rank.r2 { background: linear-gradient(140deg, #e3e9f4, #b2c0d6); color: #3d4b64; }
.rank.r3 { background: linear-gradient(140deg, #f4d1b4, #cf9163); color: #68380f; }

/* 份额条 */
.bar {
  display: block;
  width: 100%;
  min-width: 90px;
  height: 8px;
  border-radius: 5px;
  background: #eef2f9;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #6ea2ff, var(--brand));
  transition: width .3s ease;
}
.bar.gold i { background: linear-gradient(90deg, #f5c261, var(--amber-500)); }

table.grid tbody tr.row-miss td {
  background: var(--red-050) !important;
  color: #9f1239;
}
table.grid tbody tr.row-miss td:first-child { box-shadow: inset 3px 0 0 var(--red-500); }

table.grid tbody tr.total-row td {
  background: var(--surface-3) !important;
  font-weight: 700;
  color: var(--ink-900);
  border-top: 2px solid var(--line);
}

/* 首列吸左（宽表滚动时不丢标识） */
table.grid thead th:first-child,
table.grid tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line-soft);
}
table.grid thead th:first-child { z-index: 4; background: #f7f9fd; }
table.grid tbody tr:nth-child(even) td:first-child { background: var(--row-alt); }
table.grid tbody tr:hover td:first-child { background: var(--row-hover); }
table.grid tbody tr.row-miss td:first-child { background: #fdecec !important; }
table.grid tbody tr.total-row td:first-child { background: var(--surface-3) !important; }

/* ============================================================
   状态徽标
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.pill-ok { background: var(--green-050); color: var(--green-600); border-color: #c3ecd3; }
.pill-warn { background: var(--amber-050); color: var(--amber-600); border-color: #f5e0b0; }
.pill-bad { background: var(--red-050); color: var(--red-600); border-color: #f8cccc; }
.pill-info { background: var(--brand-050); color: var(--brand-700); border-color: var(--brand-100); }
.pill-purple { background: var(--purple-050); color: var(--purple-600); border-color: #ddd0fb; }
.pill-teal { background: var(--teal-050); color: var(--teal-600); border-color: #bfe9e5; }
.pill-mute { background: var(--surface-3); color: var(--ink-500); border-color: var(--line); }

/* ============================================================
   分页
   ============================================================ */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.pg-info { font-size: 12.5px; color: var(--ink-500); font-variant-numeric: tabular-nums; }
.pg-info b { color: var(--ink-900); }
.pg-ctrl { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.pg-ctrl button {
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--ink-700);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all .14s ease;
}
.pg-ctrl button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); background: var(--brand-050); }
.pg-ctrl button:disabled { opacity: .4; cursor: not-allowed; }
.pg-ctrl button.active {
  background: linear-gradient(180deg, #3d78ff, var(--brand-600));
  border-color: var(--brand-600);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(47, 107, 246, .28);
}
.pg-ctrl select {
  height: 32px;
  margin-left: 6px;
  padding: 0 26px 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--surface);
  font-size: 12.5px;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%23667085' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}

/* ============================================================
   空态 / 载入 / 提示条
   ============================================================ */
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--ink-500);
  font-size: 13.5px;
}
.empty .e-ico {
  width: 50px;
  height: 50px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--surface-3);
  border: 1px dashed var(--line);
  color: var(--ink-400);
  font-size: 20px;
  font-weight: 600;
}
.empty p { margin-top: 6px; }
.empty p:first-of-type { color: var(--ink-700); font-weight: 600; }
.empty code { margin: 0 3px; }

.skeleton {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-400);
  font-size: 13px;
}
.spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stale-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--r-md);
  background: var(--amber-050);
  border: 1px solid #f3dfae;
  color: #854d0e;
  font-size: 13px;
}
.stale-banner b { color: #78350f; }
.stale-banner.very { background: var(--red-050); border-color: #f7caca; color: #991b1b; }
.stale-banner.very b { color: #7f1d1d; }

/* ============================================================
   图表区
   ============================================================ */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.chart-card {
  padding: 16px 18px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.chart-card h4 { font-size: 13.5px; font-weight: 700; color: var(--ink-900); }
.chart-card .c-sub { margin-top: 2px; margin-bottom: 10px; font-size: 11.5px; color: var(--ink-400); }
.chart-card svg { width: 100%; height: auto; display: block; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink-500);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ============================================================
   弹窗
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 18, 36, .48);
  backdrop-filter: blur(4px);
}
.modal.show { display: flex; animation: fadeIn .16s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-4);
  overflow: hidden;
  animation: popIn .2s cubic-bezier(.2, .9, .3, 1.1);
}
.modal-box.wide { max-width: 820px; }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fdfdff, var(--surface-2));
}
.modal-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--ink-400);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink-700); }

.modal-body { padding: 20px; overflow-y: auto; }
.modal-body .field { margin-bottom: 18px; }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.modal-foot .btn-ghost:last-child, .modal-foot .btn-primary { margin-left: 0; }
.modal-foot > *:first-child { margin-right: auto; }

.modal input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 12.5px;
  cursor: pointer;
}
.modal input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 5px 12px;
  border: 0;
  border-radius: var(--r-xs);
  background: var(--brand-050);
  color: var(--brand-700);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.modal textarea {
  width: 100%;
  min-height: 130px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-family: var(--f-mono);
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
}
.modal textarea:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(47, 107, 246, .13); }
.modal select {
  height: 38px;
  padding: 0 30px 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%23667085' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
}
.modal select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(47, 107, 246, .13); }
.modal label { font-size: 13px; color: var(--ink-700); }

.import-tips {
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: var(--r-sm);
  background: var(--brand-050);
  border: 1px solid var(--brand-100);
  color: var(--ink-700);
  font-size: 12.5px;
  line-height: 1.7;
}
.import-tips b { color: var(--brand-700); }

.import-status { margin-top: 14px; font-size: 12.5px; line-height: 1.7; color: var(--ink-500); }
.import-status.ok { color: var(--green-600); font-weight: 600; }
.import-status.err { color: var(--red-600); font-weight: 600; }

/* 使用说明 */
.help-sec { margin-bottom: 22px; }
.help-sec:last-child { margin-bottom: 0; }
.help-sec h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-900);
  margin-bottom: 8px;
  padding-left: 10px;
  border-left: 3px solid var(--brand);
}
.help-sec p, .help-sec li { font-size: 13px; color: var(--ink-700); line-height: 1.8; }
.help-sec p { margin-bottom: 7px; }
.help-sec ul, .help-sec ol { margin: 6px 0; padding-left: 22px; }
.help-sec li { margin-bottom: 4px; }
.help-sec table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.help-sec th, .help-sec td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.help-sec th { background: var(--surface-3); font-weight: 600; color: var(--ink-700); font-size: 12px; }
.help-sec tr:last-child td { border-bottom: 0; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1180px) {
  :root { --side-w: 216px; }
  .content { padding: 20px 20px 36px; }
  .topbar { padding: 16px 20px; }
  .charts { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    max-height: none;
  }
  .brand { padding: 16px 18px 14px; }
  .nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 14px;
  }
  .nav-group { display: none; }
  .nav-item {
    width: auto;
    flex: none;
    margin-bottom: 0;
    padding: 7px 13px 7px 7px;
    white-space: nowrap;
    background: rgba(255, 255, 255, .05);
  }
  .nav-item.active::before { display: none; }
  .sidebar-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    flex-wrap: wrap;
  }
  .sidebar-foot .btn { height: 32px; padding: 0 12px; font-size: 12.5px; flex: 1 1 auto; }
  .sidebar-foot .btn-block { width: auto; }
  .sidebar-foot .btn-ghost { margin-top: 0 !important; }
  .sidebar-foot .src-chip { margin-bottom: 0; flex: 1 1 100%; }
  .foot-row { flex: 1 1 100%; margin-top: 0; }
  .ver { display: none; }

  .topbar { padding: 14px 16px; }
  .topbar-left h1 { font-size: 17px; }
  .content { padding: 16px 14px 32px; }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 10px; }
  .metric { padding: 13px 14px 14px; }
  .m-value { font-size: 21px; }
  .filters { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .table-wrap { max-height: none; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { max-width: none; max-height: 92vh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
}

@media (max-width: 560px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .topbar-left p { display: none; }
  table.grid { font-size: 12.2px; }
  table.grid thead th, table.grid tbody td { padding: 8px 9px; }
}

/* 打印：去掉多余的壳 */
@media print {
  .sidebar, .topbar-right, .pager, .filters, .pg-ctrl { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .table-wrap { max-height: none; overflow: visible; }
  .panel { box-shadow: none; border-color: #ccc; }
}
