* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px; color: #1f2933; background: #f2f5f8;
}
a { color: #1d5fa8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.top {
  display: flex; align-items: center; gap: 24px;
  background: #1f3a5f; color: #fff; padding: 0 20px; height: 52px;
  position: sticky; top: 0; z-index: 20;
}
.top .brand a { color: #fff; font-weight: 600; font-size: 16px; letter-spacing: .5px; }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav a {
  color: #c8d6e5; padding: 8px 12px; border-radius: 4px; font-size: 14px;
}
.top nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.top nav a.on { background: rgba(255,255,255,.16); color: #fff; }
.top .me { color: #c8d6e5; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.top .me .role { background: #3d6491; color: #fff; border-radius: 10px; padding: 1px 8px; font-size: 12px; }
.top .me a { color: #c8d6e5; }

main { max-width: 1320px; margin: 0 auto; padding: 20px; }

/* ---------- 通用 ---------- */
.card {
  background: #fff; border: 1px solid #e3e8ee; border-radius: 6px;
  padding: 16px 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; color: #33475b; font-weight: 600; }
.card h2 .sub { font-weight: 400; color: #8a97a5; font-size: 12px; margin-left: 8px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > .card { flex: 1 1 320px; }
.flash { padding: 10px 14px; border-radius: 4px; margin-bottom: 14px; }
.flash.ok { background: #e3f4e8; border: 1px solid #a9d8b8; color: #1d6b34; }
.flash.bad { background: #fdeaea; border: 1px solid #eab4b4; color: #a12b2b; }
.muted { color: #8a97a5; }
.small { font-size: 12px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head h1 { font-size: 18px; margin: 0 0 12px; color: #22303f; }

/* ---------- 表单 ---------- */
input[type=text], input[type=number], input[type=password], input[type=date],
input[type=file], select, textarea {
  border: 1px solid #cdd6e0; border-radius: 4px; padding: 7px 10px; font-size: 14px;
  font-family: inherit; background: #fff; color: #1f2933;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #4a86c8; box-shadow: 0 0 0 2px rgba(74,134,200,.15); }
label.fld { display: block; margin-bottom: 10px; }
label.fld span { display: block; font-size: 12px; color: #66788a; margin-bottom: 4px; }
label.fld input, label.fld select, label.fld textarea { width: 100%; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: #66788a; gap: 4px; }
.btn {
  display: inline-block; border: 1px solid #1d5fa8; background: #1d5fa8; color: #fff;
  padding: 7px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; font-family: inherit;
}
.btn:hover { background: #174d8a; text-decoration: none; color: #fff; }
.btn.ghost { background: #fff; color: #1d5fa8; }
.btn.ghost:hover { background: #eef4fb; }
.btn.grey { background: #fff; color: #4a5c6e; border-color: #cdd6e0; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 表格 ---------- */
table.grid { width: 100%; border-collapse: collapse; background: #fff; }
table.grid th, table.grid td { border-bottom: 1px solid #e9eef3; padding: 8px 10px; text-align: left; vertical-align: top; }
table.grid th { background: #f7f9fb; font-weight: 600; color: #4a5c6e; font-size: 13px; white-space: nowrap; }
table.grid tr:hover td { background: #fbfcfe; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.c { text-align: center; }
table.grid tr.dim td { color: #a8b3c0; }
/* 表头冻结：表格在 .wrap 里自己滚，thead 钉在框顶（像 Excel 冻结首行）。
   注意 .wrap 必须有 max-height —— 只有 overflow-x 时纵向也会被当成滚动容器，
   但高度跟内容一样，永远不会滚，sticky 就不生效了。 */
.wrap { overflow: auto; max-height: calc(100vh - 190px); }
table.grid thead th {
  position: sticky; top: 0; z-index: 6;
  box-shadow: inset 0 -1px 0 #e9eef3;
}
.btn.xs { padding: 2px 8px; font-size: 12px; border-radius: 3px; }

/* ---------- 徽标 ---------- */
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef2f6; color: #4a5c6e; }
.tag.green { background: #e3f4e8; color: #1d6b34; }
.tag.amber { background: #fdf3dc; color: #8a5b00; }
.tag.red { background: #fdeaea; color: #a12b2b; }
.tag.blue { background: #e7f0fa; color: #1d5fa8; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid #e3e8ee; border-radius: 6px; padding: 14px 16px; }
.kpi .k { font-size: 12px; color: #8a97a5; }
.kpi .v { font-size: 24px; font-weight: 600; color: #1f3a5f; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 13px; font-weight: 400; color: #8a97a5; }

/* ---------- 条形图 ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 84px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .lab { color: #4a5c6e; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar { background: #eef2f6; border-radius: 3px; height: 16px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: #4a86c8; border-radius: 3px; }
.bar-row .val { color: #66788a; font-variant-numeric: tabular-nums; }

/* ---------- 价格卡 ---------- */
.prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.prices .p { border: 1px solid #e3e8ee; border-radius: 6px; padding: 10px 12px; background: #fbfcfe; }
.prices .p .k { font-size: 12px; color: #8a97a5; }
.prices .p .v { font-size: 20px; font-weight: 600; color: #1f3a5f; font-variant-numeric: tabular-nums; }
.prices .p.low .v { color: #1d6b34; }
.prices .p.high .v { color: #a12b2b; }

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 13px; }
.pager a, .pager span { padding: 4px 10px; border: 1px solid #cdd6e0; border-radius: 4px; background: #fff; }
.pager .on { background: #1d5fa8; color: #fff; border-color: #1d5fa8; }

/* ---------- 登录 ---------- */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1f3a5f; }
body.login .box { background: #fff; padding: 32px; border-radius: 8px; width: 340px; }
body.login h1 { font-size: 18px; margin: 0 0 4px; color: #1f3a5f; }
body.login p.sub { margin: 0 0 20px; color: #8a97a5; font-size: 13px; }

@media (max-width: 720px) {
  .top { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  main { padding: 12px; }
  .bar-row { grid-template-columns: 72px 1fr 70px; }
}
