:root {
  --bg: #f6f8fb; --card: #ffffff; --line: #e6e9ef; --fg: #1f2937; --muted: #6b7280; --faint: #9ca3af;
  --blue: #2f7cf6; --blue-soft: #eaf2ff; --green: #22c55e; --green-ink: #16a34a; --red: #ef4444; --amber: #f59e0b; --ring: #e9edf3;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
h2 { margin: 0; font-size: 17px; font-weight: 700; }
p { margin: 0; }

/* 左侧导航 */
.side { position: fixed; inset: 0 auto 0 0; width: 204px; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 6px 10px 18px; }
.logo .mark { width: 26px; height: 26px; border-radius: 8px; background: var(--blue); position: relative; }
.logo .mark::after { content: ""; position: absolute; left: 6px; top: 8px; width: 14px; height: 8px; background: #fff; border-radius: 6px 6px 4px 4px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); margin-bottom: 4px; }
.side nav a i { font-style: normal; width: 18px; text-align: center; color: var(--faint); font-size: 15px; }
.side nav a.on { background: var(--blue-soft); color: var(--blue); font-weight: 600; } .side nav a.on i { color: var(--blue); }
.side nav a:hover:not(.on) { background: #f3f4f6; color: var(--fg); }
.side-foot { margin-top: auto; padding: 10px 12px; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.side-foot small { color: var(--faint); margin-left: auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }

.page { margin-left: 204px; min-height: 100vh; display: flex; flex-direction: column; }

/* 顶栏 */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; height: 60px; padding: 0 28px; background: var(--card); border-bottom: 1px solid var(--line); }
.stats { display: flex; align-items: center; gap: 0; color: var(--muted); font-size: 13px; }
.stats span { padding: 0 18px; border-left: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.stats span:first-child { border-left: 0; padding-left: 0; }
.stats b { color: var(--fg); font-family: var(--mono); font-weight: 600; }
.links { margin-left: auto; display: flex; align-items: center; gap: 22px; font-size: 13px; }
.links a { color: var(--blue); } .links a:hover { text-decoration: underline; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #e5e7eb; position: relative; overflow: hidden; }
.avatar::after { content: ""; position: absolute; left: 9px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 14px 0 4px #fff; }

main { padding: 22px 28px 20px; flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 22px 0; }
.card-h p { color: var(--faint); font-size: 12px; margin-top: 4px; }
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); background: #f3f4f6; padding: 6px 12px; border-radius: 999px; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

/* 地图 */
.map-card { margin-bottom: 22px; }
.map { position: relative; overflow: hidden; aspect-ratio: 3.4 / 1; margin: 0 8px 8px; }
.world { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; opacity: .5; }
.pins { position: absolute; inset: 0; }
.pin { position: absolute; width: 10px; height: 10px; transform: translate(-50%, -50%); border-radius: 50%; background: var(--blue); border: 2px solid #fff; box-shadow: 0 0 0 3px rgba(47,124,246,.18); }
.pin.off { background: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,.18); }
.pin span { position: absolute; top: 50%; left: 18px; transform: translateY(-50%); white-space: nowrap; font: 600 11px/1 var(--mono); background: #fff; border: 1px solid var(--line); padding: 4px 8px; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.pin.r span { left: auto; right: 18px; }
.pin.below span { top: auto; left: auto; right: 14px; bottom: -26px; transform: none; }
.pin.above-l span { top: auto; left: auto; right: 14px; bottom: 12px; transform: none; }
.pin.above span { top: auto; left: 14px; bottom: 12px; transform: none; }

/* 列表头 */
.list-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.list-h p { color: var(--faint); font-size: 12px; }
.list-h > div:first-child { display: flex; align-items: baseline; gap: 12px; }
.tools { display: flex; gap: 10px; align-items: center; }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; height: 38px; width: 240px; color: var(--faint); }
.search input { border: 0; outline: 0; background: transparent; font: inherit; color: var(--fg); width: 100%; }
.btn { display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 13px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

/* 卡片 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 18px; }
.srv { padding: 20px 22px 18px; }
.srv .h { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.srv .flag { width: 44px; height: 32px; border-radius: 6px; object-fit: cover; box-shadow: 0 0 0 1px var(--line); background: #f3f4f6; }
.srv .name { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.srv .name .st { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.srv.off .name .st { background: var(--red); }
.srv .sub { color: var(--faint); font-size: 12px; margin-top: 2px; font-family: var(--mono); }
.srv .spec { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); background: #f3f4f6; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.body { display: grid; grid-template-columns: 1fr 1px auto; gap: 0 22px; align-items: center; }
.gauges { display: flex; justify-content: space-between; padding: 0 8px; }
.g { text-align: center; }
.g svg { width: 74px; height: 74px; display: block; margin: 0 auto 6px; }
.g circle { fill: none; stroke-width: 5; stroke-linecap: round; }
.g .track { stroke: var(--ring); }
.g .val { stroke: var(--blue); transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .4s; }
.g .val.warn { stroke: var(--amber); } .g .val.bad { stroke: var(--red); }
.g text { font: 600 13px var(--mono); fill: var(--fg); }
.g small { color: var(--faint); font-size: 11px; }
.vline { width: 1px; height: 86px; background: var(--line); }
.meta { display: grid; gap: 12px; font-size: 13px; color: var(--muted); min-width: 120px; }
.meta span { display: flex; align-items: center; gap: 8px; }
.meta b { color: var(--fg); font-family: var(--mono); font-weight: 600; }
.meta .up b { color: var(--blue); } .meta .down b { color: var(--green-ink); }
.meta i { font-style: normal; width: 14px; text-align: center; color: var(--faint); }
.meta .up i { color: var(--blue); } .meta .down i { color: var(--green-ink); }
.quota { margin-top: 16px; }
.quota .t { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.quota .t b { color: var(--fg); font-weight: 600; }
.quota .bar { height: 6px; background: var(--ring); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.quota .bar i { display: block; height: 100%; min-width: 6px; background: var(--blue); border-radius: 3px; transition: width .4s; }
.quota .bar i.warn { background: var(--amber); } .quota .bar i.bad { background: var(--red); }

footer { text-align: center; color: var(--faint); font-size: 12px; padding: 0 0 20px; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--faint); padding: 40px; }

@media (max-width: 1100px) { .grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .side { display: none; } .page { margin-left: 0; }
  .top { padding: 0 14px; height: 52px; } .stats span { padding: 0 10px; } .stats span:nth-child(n+3) { display: none; }
  .links { gap: 12px; } .avatar { display: none; }
  main { padding: 12px 12px 16px; }
  .map { aspect-ratio: 2.4 / 1; margin: 0 4px 4px; } .pin span { display: none; }
  .map-card { margin-bottom: 14px; } .card-h { padding: 14px 16px 0; }
  .list-h { flex-direction: column; align-items: stretch; gap: 10px; } .search { width: 100%; } .btn.primary { display: none; }
  .grid { gap: 12px; } .srv { padding: 16px; }
  .body { grid-template-columns: 1fr; gap: 12px; } .vline { display: none; }
  .meta { grid-template-columns: repeat(3, 1fr); min-width: 0; }
  .g svg { width: 64px; height: 64px; }
}

/* 页内视图 */
.view[hidden] { display: none; }
.tbl-card { overflow: hidden; }
.tbl-card + .tbl-card, .tbl-card .sub-h { margin-top: 16px; }
.tbl-card .sub-h { padding: 16px 20px 0; font-weight: 700; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--faint); font-size: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 14px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .mono { font-family: var(--mono); }
.tbl .name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tbl .name img { width: 22px; height: 16px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.chip { display: inline-block; font: 500 11px/1 var(--mono); padding: 5px 9px; border-radius: 999px; background: #f3f4f6; color: var(--muted); }
.chip.on { background: #e8f7ee; color: var(--green-ink); } .chip.off { background: #fdecec; color: var(--red); } .chip.blue { background: var(--blue-soft); color: var(--blue); }
.mini { width: 120px; height: 6px; background: var(--ring); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.mini i { display: block; height: 100%; background: var(--blue); min-width: 3px; }
.kv { display: grid; grid-template-columns: 180px 1fr; }
.kv > div { padding: 13px 20px; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.note { padding: 28px; text-align: center; color: var(--faint); font-size: 13px; }

/* 内嵌后台 */
.frame-card { overflow: hidden; }
#frame { display: block; width: 100%; border: 0; min-height: 420px; height: 70vh; background: var(--card); opacity: 0; transition: opacity .15s; }
#frame.ready { opacity: 1; }

/* 深色:跟随系统 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #161a20; --line: #262b33; --fg: #e5e7eb; --muted: #9ca3af; --faint: #6b7280;
    --blue: #4f8ff7; --blue-soft: #1b2a44; --green: #22c55e; --green-ink: #4ade80; --red: #f87171; --amber: #fbbf24; --ring: #262b33;
  }
  .side nav a:hover:not(.on) { background: #1c2129; }
  .cpu-mem-group, .srv .spec, .badge { background: #1f2530 !important; }
  .search, .btn { background: var(--card); }
  .world { opacity: .22; filter: invert(1) brightness(.9); }
  .pin span { background: #1c2129; color: var(--fg); }
  .srv .flag { box-shadow: 0 0 0 1px var(--line); }
  .avatar { background: #2a3038; } .avatar::after { background: #4b5563; box-shadow: 0 14px 0 4px #4b5563; }
  .quota .bar, .g .track { background: var(--ring); }
  .srv:hover { box-shadow: 0 4px 16px rgba(0,0,0,.4); }
}
