:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --tx1: #1d1d1f;
  --tx2: #5c5c61;
  --tx3: #86868b;
  --bd: rgba(60, 60, 67, .14);
  --bd2: rgba(60, 60, 67, .08);
  --acc: #0071e3;
  --acc-soft: rgba(0, 113, 227, .09);
  --up: #d92626;
  --dn: #0a8f4d;
  --warn: #b26a00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--tx1);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.dn { color: var(--dn); }
.mut { color: var(--tx3); }

/* ---------- 顶栏 ---------- */
header {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--bd);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.brand i {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(160deg, #0071e3, #004a99);
  color: #fff; font-style: normal; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.tag {
  font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: var(--acc-soft); color: var(--acc); font-weight: 600;
}
.meta { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--tx2); font-size: 12px; }

input[type=text], input[type=number], select {
  height: 28px; padding: 0 8px; border: 1px solid var(--bd); border-radius: 7px;
  background: #fff; color: var(--tx1); font-size: 12.5px; outline: none;
  font-family: inherit;
}
input[type=text]:focus, input[type=number]:focus, select:focus { border-color: var(--acc); }
input[type=checkbox] { accent-color: var(--acc); width: 14px; height: 14px; }

.search { width: 220px; }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 318px 1fr; height: calc(100vh - 52px); }

aside {
  border-right: 1px solid var(--bd);
  overflow-y: auto;
  background: #fbfbfd;
  padding: 10px 10px 40px;
}

.mod {
  background: var(--card);
  border: 1px solid var(--bd2);
  border-radius: var(--radius);
  margin-bottom: 7px;
  overflow: hidden;
}
.mod > summary {
  list-style: none; cursor: pointer; padding: 9px 10px;
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.mod > summary::-webkit-details-marker { display: none; }
.mod .no {
  font-size: 10.5px; font-weight: 700; color: var(--acc);
  background: var(--acc-soft); padding: 2px 5px; border-radius: 4px; min-width: 20px; text-align: center;
}
.mod .nm { font-weight: 600; font-size: 12.5px; }
.mod .st { margin-left: auto; font-size: 11px; color: var(--tx3); }
.mod.on { border-color: rgba(0, 113, 227, .35); }
.mod.on .st { color: var(--acc); font-weight: 600; }
.mod .body { padding: 4px 10px 10px; border-top: 1px solid var(--bd2); }

.row { display: flex; align-items: center; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.row > label { display: flex; align-items: center; gap: 5px; cursor: pointer; color: var(--tx2); }
.lbl { color: var(--tx3); font-size: 11.5px; min-width: 46px; }
.hint { color: var(--tx3); font-size: 11px; line-height: 1.5; margin-top: 4px; }

/* ---------- 结果区 ---------- */
main { display: flex; flex-direction: column; overflow: hidden; }

.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--bd); background: #fff;
}
.stat { display: flex; align-items: baseline; gap: 5px; }
.stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--tx3); font-size: 11.5px; }
.bar .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.tablewrap { flex: 1; overflow: auto; }

table { width: 100%; border-collapse: separate; border-spacing: 0; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: #fafafc; color: var(--tx2); font-size: 11.5px; font-weight: 600;
  text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--bd);
  white-space: nowrap;
}
thead th:first-child, thead th:nth-child(2) { text-align: left; }
tbody td {
  padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--bd2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
tbody td:first-child, tbody td:nth-child(2) { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f5f8ff; }
tbody tr.sel { background: var(--acc-soft); }
.code { color: var(--tx3); font-size: 11.5px; }
.name { font-weight: 600; }
.pill {
  display: inline-block; padding: 1px 5px; border-radius: 4px; font-size: 10.5px;
  background: #f0f0f4; color: var(--tx2); margin-left: 5px;
}
.pill.lu { background: rgba(217, 38, 38, .1); color: var(--up); }
.pill.st { background: rgba(178, 106, 0, .12); color: var(--warn); }

.empty { padding: 60px 20px; text-align: center; color: var(--tx3); }

.pager {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px; border-top: 1px solid var(--bd); background: #fff;
}
.pager button {
  height: 28px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--bd);
  background: #fff; color: var(--tx1); cursor: pointer; font-size: 12.5px; font-family: inherit;
}
.pager button:disabled { color: var(--tx3); cursor: default; background: #fafafa; }
.pager button:not(:disabled):hover { border-color: var(--acc); color: var(--acc); }

/* ---------- 抽屉 ---------- */
.drawer {
  position: fixed; top: 52px; right: 0; bottom: 0; width: 620px; max-width: 92vw;
  background: #fff; border-left: 1px solid var(--bd); box-shadow: -8px 0 30px rgba(0, 0, 0, .07);
  transform: translateX(100%); transition: transform .22s ease; z-index: 30;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.dh { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--bd); }
.dh .t { font-size: 15px; font-weight: 600; }
.dh .x { margin-left: auto; cursor: pointer; color: var(--tx3); font-size: 18px; line-height: 1; padding: 4px; }
.dbody { flex: 1; overflow-y: auto; padding: 12px 14px 30px; }

canvas { width: 100%; display: block; }

.grid2 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.kv { background: #fafafc; border: 1px solid var(--bd2); border-radius: 8px; padding: 8px 10px; }
.kv .k { color: var(--tx3); font-size: 11px; margin-bottom: 3px; }
.kv .v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

h4 { margin: 16px 0 8px; font-size: 12.5px; color: var(--tx2); font-weight: 600; }
.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini th, .mini td { padding: 5px 7px; border-bottom: 1px solid var(--bd2); text-align: right; }
.mini th { color: var(--tx3); font-weight: 500; text-align: right; background: none; position: static; }
.mini th:first-child, .mini td:first-child { text-align: left; }

.loading { padding: 24px; text-align: center; color: var(--tx3); }
