:root {
  --bg: #ffffff;
  --card: #fafafa;
  --card-2: #f4f4f4;
  --line: #ececec;
  --text: #161616;
  --muted: #8d8d8d;
  --muted-2: #b0b0b0;
  --accent: #1a1a1a;
  --green: #22c55e;
  --blue: #2f6df6;
  --red: #e5484d;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand .dot {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1a1a1a, #4a4a4a);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
}

nav { display: flex; gap: 4px; }

nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

nav a:hover { background: var(--card-2); color: var(--text); }
nav a.active { color: var(--text); background: var(--card-2); font-weight: 550; }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 30px 32px 80px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
}

h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 30px 0 12px;
  letter-spacing: -0.01em;
}

.sub, .muted { color: var(--muted); font-size: 12.5px; }
.link { color: var(--muted); font-size: 12.5px; }
.link:hover { color: var(--text); }

/* stat bar */
.statbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat { padding: 16px 20px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .k { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.stat .v { font-size: 22px; font-weight: 560; letter-spacing: -0.02em; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.stat .note { font-size: 11.5px; color: var(--muted-2); margin-top: 6px; }

/* card */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card.flat { padding: 0; overflow: hidden; }

/* flow diagram */
.flow {
  display: grid;
  grid-template-columns: 1fr 260px 1fr;
  gap: 0;
  align-items: center;
  padding: 22px 20px;
  margin-top: 16px;
}

.flow-col h3 {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 8px;
  display: flex;
  justify-content: space-between;
}

.node {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}

.node .ico {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  flex: 0 0 auto;
}

.node .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .tag { color: var(--muted); font-size: 11.5px; }
.node .count { font-variant-numeric: tabular-nums; font-size: 12px; }

.node.ghost { background: transparent; border-style: dashed; color: var(--muted); justify-content: center; cursor: pointer; }
.node.ghost:hover { background: var(--card-2); }

.core {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.core .badge-icon {
  width: 26px; height: 26px; border-radius: 8px;
  background: #1a1a1a; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; margin-bottom: 6px;
}

.core .t { font-weight: 600; font-size: 13px; }
.core .ip { font-size: 11px; color: var(--muted); margin-top: 2px; }
.core .desc { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
.core .metrics {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
}
.core .metrics div span { display: block; font-size: 10.5px; color: var(--muted); }
.core .metrics div b { font-size: 14px; font-weight: 560; }

/* rows */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.row:first-child { border-top: 0; }
.row:hover { background: #f6f6f6; }

/* provider pool list */
.pool { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pool .row { padding: 12px 16px; }

.p-detail { padding: 4px 16px 16px 48px; border-top: 1px solid var(--line); background: #fcfcfc; }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 12px; padding: 4px 0; font-size: 12.5px; }
.kv .k { color: var(--muted); }

.keyline {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card-2); border-radius: 8px; padding: 4px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
.keyline .eye { color: var(--muted); font-size: 11px; cursor: pointer; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card-2); border: 1px solid transparent;
  border-radius: 8px; padding: 2px 9px; font-size: 12px; color: #444;
}
.chip.plain { background: #eef1f7; }
.chip .x { color: var(--muted); cursor: pointer; font-size: 11px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: #fff;
}

.toggle {
  width: 38px; height: 22px; border-radius: 999px; background: #d9d9d9;
  border: 0; position: relative; transition: background 0.18s; flex: 0 0 auto;
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform 0.18s; box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(16px); }

.dot-state { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot-state.off { background: #ccc; }
.dot-state.err { background: var(--red); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 9px; padding: 7px 13px; font-size: 12.5px;
}
.btn:hover { background: var(--card-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { opacity: 0.9; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 11px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: #c9c9c9; box-shadow: 0 0 0 3px #f2f2f2; }
select { appearance: none; background-image: none; cursor: pointer; }
.search { position: relative; flex: 1; }
.search input { padding-left: 32px; background: var(--card); }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 6px; color: var(--muted); font-size: 14px; }

/* request list */
.req { display: flex; align-items: flex-start; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.req:first-child { border-top: 0; }
.req .body { flex: 1; min-width: 0; }
.req .title { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.req .title b { font-weight: 560; }
.req .meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; margin-top: 3px; flex-wrap: wrap; }
.req .right { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.req .right .ok { color: var(--green); }

/* tabs */
.tabs { display: inline-flex; gap: 4px; background: var(--card-2); padding: 3px; border-radius: 10px; }
.tabs button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; font-size: 12.5px; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 200px; padding: 18px 0 0; position: relative; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 2px; position: relative; }
.chart .bar { width: 100%; background: #b9b9b9; border-radius: 2px 2px 0 0; }
.chart .bar.cached { background: #7fbf9a; }
.chart .bar.out { background: #1f1f1f; }
.chart .col:hover .bar { filter: brightness(0.92); }
.chart .col .tip {
  display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #1a1a1a; color: #fff; font-size: 11px; padding: 6px 8px; border-radius: 7px;
  white-space: nowrap; z-index: 5; margin-bottom: 6px;
}
.chart .col:hover .tip { display: block; }
.axis { display: flex; justify-content: space-between; color: var(--muted-2); font-size: 11px; margin-top: 8px; }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* modal */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.28);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px; z-index: 50; overflow: auto;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18); padding: 22px 24px;
}
.modal h3 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.modal .sub { margin-bottom: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* login */
.login-wrap { max-width: 360px; margin: 14vh auto; text-align: center; }
.login-wrap h1 { font-size: 22px; margin-bottom: 6px; }
.login-wrap .card { padding: 22px; text-align: left; margin-top: 20px; }

/* misc */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.flex { display: flex; align-items: center; }
.gap8 { gap: 8px; }
.spacer { flex: 1; }
.right { text-align: right; }
.wrap { flex-wrap: wrap; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.pill-line { font-size: 11.5px; color: var(--muted); }
.hidden { display: none !important; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1a1a1a; color: #fff; padding: 9px 16px; border-radius: 10px;
  font-size: 13px; z-index: 100; opacity: 0; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

@media (max-width: 860px) {
  .statbar { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .stat:nth-child(4) { border-top: 1px solid var(--line); }
  .flow { grid-template-columns: 1fr; gap: 14px; }
  main { padding: 22px 16px 60px; }
  .topbar { padding: 0 16px; gap: 14px; overflow-x: auto; }
  .core { order: -1; }
}
