:root {
  --bg: #070d18;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, rgba(30, 78, 150, .22), transparent 60%),
             radial-gradient(900px 500px at 100% 0%, rgba(59, 130, 246, .12), transparent 55%),
             #070d18;
  --surface: rgba(15, 25, 43, .82);
  --surface-solid: #0e1828;
  --surface-hover: rgba(24, 38, 62, .9);
  --line: rgba(94, 136, 190, .18);
  --line-strong: rgba(94, 136, 190, .32);
  --text: #e9f1fc;
  --text-2: #a3b5cd;
  --text-3: #6f8199;
  --accent: #4f9cff;
  --accent-2: #2f7ff0;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 14px 40px rgba(0, 0, 0, .35);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg-grad);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1680px; margin: 0 auto; padding: 20px 24px 40px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; padding: 6px 0 14px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px; color: #cfe3ff;
  display: grid; place-items: center;
  background: linear-gradient(160deg, rgba(79, 156, 255, .28), rgba(30, 64, 120, .25));
  border: 1px solid rgba(79, 156, 255, .35);
  box-shadow: 0 0 26px rgba(59, 130, 246, .18) inset;
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-mark.big { width: 56px; height: 56px; margin: 0 auto 12px; }
.brand-mark.big svg { width: 32px; height: 32px; }
.brand-text h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: .2px; }
.brand-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.conn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid var(--line); background: rgba(10, 18, 32, .7); color: var(--text-2);
}
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.conn[data-state="ok"] { color: #9fe3b6; border-color: rgba(34, 197, 94, .35); }
.conn[data-state="ok"] .dot { background: var(--ok); box-shadow: 0 0 8px rgba(34, 197, 94, .8); }
.conn[data-state="warn"] { color: #f6d08a; border-color: rgba(245, 158, 11, .35); }
.conn[data-state="warn"] .dot { background: var(--warn); }
.conn[data-state="error"] { color: #f6a6a6; border-color: rgba(239, 68, 68, .4); }
.conn[data-state="error"] .dot { background: var(--danger); }
.conn[data-state="loading"] .dot { background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.field { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); }
.field.col { flex-direction: column; align-items: stretch; gap: 6px; }
.field select, .field input, .filters input, .filters select {
  background: rgba(10, 18, 32, .85); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 13px; font-family: inherit; outline: none;
}
.field select:focus, .field input:focus, .filters input:focus, .filters select:focus {
  border-color: var(--accent);
}
.custom-range { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line-strong); background: rgba(18, 30, 50, .9);
  color: var(--text); font-size: 13px; font-family: inherit; text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-hover); border-color: rgba(120, 168, 226, .45); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #3d8bf5, #2f74d8); border-color: #4f9cff; color: #fff; }
.btn-primary:hover { background: linear-gradient(180deg, #4f9cff, #3a82e8); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.spin { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

.meta-line { display: flex; gap: 10px; flex-wrap: wrap; color: var(--text-3); font-size: 12.5px; margin-bottom: 14px; }
.sep { color: var(--line-strong); }

.alert {
  border: 1px solid rgba(239, 68, 68, .4); background: rgba(80, 20, 30, .35);
  color: #ffc9c9; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 13px;
}
.alert.warn { border-color: rgba(245, 158, 11, .4); background: rgba(80, 55, 15, .3); color: #ffe1a8; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .2px; }
.hint { font-size: 12px; color: var(--text-3); }

.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 12.5px; color: var(--text-2); }
.stat-badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text-3); }
.stat-badge.up { color: #f6a6a6; border-color: rgba(239,68,68,.45); }
.stat-badge.down { color: #9fe3b6; border-color: rgba(34,197,94,.45); }
.stat-value { font-size: 26px; font-weight: 650; margin: 6px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.stat-value.na { font-size: 15px; color: var(--text-3); font-weight: 500; }
.stat-hint { font-size: 11.5px; color: var(--text-3); }

.grid-main { display: grid; grid-template-columns: 320px minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
.side { display: grid; gap: 14px; }

/* ---------------- 排名 ---------------- */
.rank-head, .rank-list li { display: grid; grid-template-columns: 26px minmax(0,1fr) 56px 56px 52px; gap: 6px; align-items: center; }
.rank-head { font-size: 11.5px; color: var(--text-3); padding: 0 4px 8px; border-bottom: 1px solid var(--line); }
.rank-list { list-style: none; margin: 0; padding: 4px 0 0; }
.rank-list li { padding: 7px 4px; border-radius: 8px; font-size: 13px; }
.rank-list li:hover { background: rgba(40, 70, 120, .25); cursor: pointer; }
.rank-list li.placeholder { display: block; color: var(--text-3); font-size: 12.5px; cursor: default; }
.rank-list .rk { color: var(--text-3); font-variant-numeric: tabular-nums; }
.rank-list .nm { display: flex; align-items: center; gap: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.rank-list .share { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-3); }
.flag { width: 18px; height: 13px; border-radius: 2px; object-fit: cover; background: rgba(255,255,255,.08); }
.link-more { margin-top: 10px; width: 100%; background: none; border: 1px dashed var(--line-strong); color: var(--text-2); border-radius: 8px; padding: 7px; cursor: pointer; font-size: 12.5px; }
.link-more:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------- 地图 ---------------- */
.map-wrap { position: relative; height: 380px; border-radius: 10px; overflow: hidden; background: radial-gradient(600px 300px at 50% 40%, rgba(26, 52, 92, .35), transparent 70%); }
#world-map { width: 100%; height: 100%; display: block; cursor: grab; }
#world-map.dragging { cursor: grabbing; }
#world-map .country {
  fill: rgba(44, 70, 108, .45);
  stroke: rgba(8, 14, 24, .9);
  stroke-width: .4;
  transition: fill .15s;
}
#world-map .country.l1 { fill: rgba(47, 111, 196, .55); }
#world-map .country.l2 { fill: rgba(54, 140, 232, .72); }
#world-map .country.l3 { fill: #f59e0b; }
#world-map .country.l4 { fill: #ef4444; }
#world-map .country:hover { stroke: #9fc7ff; stroke-width: 1; }
#world-map .country.active { stroke: #fff; stroke-width: 1.2; }
.map-ctrl { position: absolute; top: 10px; right: 10px; display: grid; gap: 4px; }
.map-ctrl button {
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer;
  background: rgba(10, 18, 32, .85); color: var(--text); border: 1px solid var(--line-strong); font-size: 15px;
}
.map-ctrl button:hover { border-color: var(--accent); color: var(--accent); }
.map-legend { position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); background: rgba(8, 14, 26, .72); padding: 5px 9px; border-radius: 8px; border: 1px solid var(--line); }
.map-legend span { margin-right: 4px; color: var(--text-3); }
.map-legend em { font-style: normal; margin-right: 6px; color: var(--text-3); }
.lg { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.lg0 { background: rgba(44, 70, 108, .75); }
.lg1 { background: rgba(47, 111, 196, .75); }
.lg2 { background: rgba(54, 140, 232, .85); }
.lg3 { background: #f59e0b; }
.lg4 { background: #ef4444; }
.map-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(8, 14, 26, .95); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--text);
  box-shadow: var(--shadow); min-width: 150px;
}
.map-tip b { color: var(--accent); }
.map-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: 13px; background: rgba(8,14,26,.85); }
.country-list { max-height: 380px; overflow: auto; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; }
.country-list .cl-item { display: flex; justify-content: space-between; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; }
.country-list .cl-item:hover { border-color: var(--accent); cursor: pointer; }

/* ---------------- 趋势 ---------------- */
.trend { height: 150px; }
.trend svg { width: 100%; height: 100%; display: block; }
.trend .bar-ban { fill: #4f9cff; }
.trend .bar-unban { fill: #22c55e; }
.trend .bar-restore { fill: #f59e0b; }
.trend .grid-line { stroke: rgba(94,136,190,.12); stroke-width: 1; }
.trend .gap-band { fill: rgba(239,68,68,.08); }
.trend .axis { fill: var(--text-3); font-size: 9.5px; }
.trend .bar-hit { fill: transparent; cursor: pointer; }
.trend .bar-hit:hover { fill: rgba(79,156,255,.08); }
.legend-row { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend-row i, .donut-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; }
.dot-ban { background: #4f9cff; }
.dot-unban { background: #22c55e; }
.dot-restore { background: #f59e0b; }

/* ---------------- 环形图 ---------------- */
.donut-wrap { display: flex; align-items: center; gap: 14px; }
#donut { width: 120px; height: 120px; flex: 0 0 120px; }
.donut-legend { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--text-2); display: grid; gap: 7px; }
.donut-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.donut-center { fill: var(--text); font-size: 15px; font-weight: 600; }
.donut-sub { fill: var(--text-3); font-size: 6px; }

/* ---------------- 表格 ---------------- */
.table-card { margin-top: 14px; }
.tabs { display: inline-flex; gap: 4px; background: rgba(10, 18, 32, .7); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tabs button, .seg button {
  border: 0; background: transparent; color: var(--text-2); padding: 6px 12px;
  border-radius: 8px; cursor: pointer; font-size: 12.5px; font-family: inherit;
}
.tabs button.active, .seg button.active { background: rgba(79, 156, 255, .18); color: var(--accent); }
.seg { display: inline-flex; gap: 3px; background: rgba(10, 18, 32, .7); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input { width: 150px; }
.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 900px; }
.data-table th {
  text-align: left; font-weight: 500; color: var(--text-3); font-size: 11.5px;
  padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: rgba(10, 18, 32, .6); position: sticky; top: 0;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid rgba(94, 136, 190, .08); white-space: nowrap; }
.data-table tbody tr:hover { background: rgba(40, 70, 120, .18); }
.data-table .mono { font-family: var(--mono); font-size: 12px; }
.data-table .td-state { text-align: center; color: var(--text-3); padding: 32px; }
.status-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid; }
.status-banned { color: #ffb4b4; border-color: rgba(239,68,68,.5); background: rgba(239,68,68,.12); }
.status-unbanned { color: #a8e6bf; border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.1); }
.status-unknown { color: var(--text-3); border-color: var(--line-strong); }
.type-pill { font-size: 11px; padding: 2px 8px; border-radius: 6px; }
.type-ban { background: rgba(79,156,255,.16); color: #9cc7ff; }
.type-unban { background: rgba(34,197,94,.14); color: #9fe3b6; }
.type-restore { background: rgba(245,158,11,.15); color: #f6d08a; }
.type-increase { background: rgba(148,163,184,.14); color: #c3cedd; }
.row-link { color: var(--accent); cursor: pointer; background: none; border: 0; font-size: 12px; font-family: inherit; }
.row-link:hover { text-decoration: underline; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.pager-btns { display: flex; align-items: center; gap: 10px; }

.foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; color: var(--text-3); font-size: 11.5px; }

/* ---------------- 抽屉 ---------------- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-mask { position: absolute; inset: 0; background: rgba(3, 7, 14, .65); backdrop-filter: blur(2px); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(520px, 94vw);
  background: #0b1424; border-left: 1px solid var(--line-strong);
  box-shadow: -20px 0 50px rgba(0,0,0,.45); display: flex; flex-direction: column;
  animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .5; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 14px; }
.drawer-body { padding: 12px 16px 24px; overflow: auto; }
.tl-item { display: grid; grid-template-columns: 128px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px dashed rgba(94,136,190,.14); font-size: 12.5px; }
.tl-item time { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; }

/* ---------------- 登录 ---------------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 30px 28px; box-shadow: var(--shadow); text-align: center;
}
.login-card h1 { margin: 0; font-size: 19px; }
.login-sub { color: var(--text-3); font-size: 12.5px; margin: 6px 0 20px; }
.login-card form { display: grid; gap: 12px; text-align: left; }
.login-error { color: #ffb4b4; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; }
.login-foot { color: var(--text-3); font-size: 11.5px; margin: 18px 0 0; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1500px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1280px) {
  .grid-main { grid-template-columns: 280px minmax(0, 1fr); }
  .side { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app { padding: 14px; }
  .grid-main { grid-template-columns: 1fr; }
  .side { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-wrap { height: 300px; }
  .brand-text h1 { font-size: 18px; }
}
