/* ===== cfmon 面板样式 ===== */
:root {
  --bg: #080b11;
  --bg-soft: #0c1119;
  --panel: #10161f;
  --panel-2: #0d131c;
  --line: #1c2634;
  --line-soft: #161f2b;
  --text: #e8eef8;
  --muted: #8494a9;
  --dim: #5b6a80;
  --accent: #4c8dff;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -18px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(76, 141, 255, .10), transparent 60%),
    radial-gradient(900px 500px at 88% 0%, rgba(52, 211, 153, .06), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
b { font-weight: 600; }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #18212e, #121a25);
  color: var(--text);
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .08s, color .16s;
  white-space: nowrap;
}
.btn:hover { border-color: #2b3a4d; background: linear-gradient(180deg, #1d2836, #151e2a); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  border-color: #2b5fc4;
  background: linear-gradient(180deg, #4c8dff, #3568d4);
  color: #fff;
  box-shadow: 0 6px 18px -10px #4c8dff;
}
.btn.primary:hover { background: linear-gradient(180deg, #5b98ff, #3b71e0); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: #151e2a; }
.btn.danger { color: var(--bad); border-color: #40232a; }
.btn.danger:hover { background: #22131a; border-color: #5a2b34; }
.btn.block { width: 100%; padding: 10px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0a1017;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
input:focus { border-color: #2f5fbf; box-shadow: 0 0 0 3px rgba(76, 141, 255, .13); }
input::placeholder { color: #4d5b70; }

/* ---------- 登录页 ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  padding: 30px 26px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(22, 30, 42, .9), rgba(12, 17, 24, .95));
  box-shadow: var(--shadow), 0 40px 80px -60px #4c8dff;
  text-align: center;
}
.login-card h1 { font-size: 19px; margin: 14px 0 4px; letter-spacing: .2px; }
.login-card p { margin: 0 0 20px; font-size: 13px; }
.login-card input { margin-bottom: 12px; text-align: center; letter-spacing: 2px; }
.login-card button + button { margin-top: 8px; }
.logo-big {
  width: 46px; height: 46px; margin: 0 auto;
  border-radius: 13px;
  background: linear-gradient(150deg, #5b9dff, #2f5fd0);
  box-shadow: 0 12px 30px -14px #4c8dff;
  position: relative;
}
.logo-big::after {
  content: ""; position: absolute; inset: 0;
  background: no-repeat center/26px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M6 21l5-7 5 4 5-9 5 12' stroke='white' stroke-width='2.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.form-err { color: var(--bad); font-size: 12.5px; min-height: 18px; margin: 10px 0 0 !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 11, 17, .78);
  backdrop-filter: blur(14px) saturate(140%);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 15.5px; margin: 0; letter-spacing: .3px; font-weight: 650; }
.logo {
  width: 24px; height: 24px; border-radius: 7px;
  background: linear-gradient(150deg, #5b9dff, #2f5fd0);
  position: relative;
}
.logo::after {
  content: ""; position: absolute; inset: 0;
  background: no-repeat center/15px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M6 21l5-7 5 4 5-9 5 12' stroke='white' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.env {
  font-size: 11px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 20px; padding: 1px 8px;
}

/* 游客模式：状态可见，写操作全部隐藏 */
body.guest .admin-only { display: none !important; }
body:not(.guest) .guest-only { display: none !important; }

.badge-guest {
  font-size: 11px;
  color: #9fb2c9;
  background: #16202c;
  border: 1px solid #243244;
  border-radius: 20px;
  padding: 1px 8px;
  letter-spacing: .3px;
}
.summary {
  flex: 1;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 0;
  font-size: 12.5px; color: var(--muted);
}
.summary > span { display: inline-flex; align-items: baseline; gap: 4px; }
.summary > span + span { border-left: 1px solid #1b2532; padding-left: 14px; margin-left: 14px; }
.summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.summary .sep { color: #2a3646; }
.actions { display: flex; align-items: center; gap: 8px; }

.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .5);
  animation: pulse 2.6s infinite;
  margin-right: 2px;
}
.pulse.stale { background: var(--warn); animation: none; box-shadow: none; }
.pulse.err { background: var(--bad); animation: none; box-shadow: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .45); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ---------- 网格 ---------- */
main { padding: 20px 22px 8px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--shadow);
  padding: 14px 15px 10px;
  cursor: pointer;
  transition: border-color .18s, transform .12s, box-shadow .18s;
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(120, 170, 255, .35), transparent);
  opacity: 0; transition: opacity .2s;
}
.card:hover { border-color: #2a3949; transform: translateY(-2px); }
.card:hover::before { opacity: 1; }
.card.offline { opacity: .62; }
.card.offline:hover { opacity: .8; }

.card-head { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.card-head h2 {
  font-size: 14.5px; margin: 0; font-weight: 600;
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #3c4a5e; flex: none;
}
.dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(52, 211, 153, .75); }
.tag {
  margin-left: auto;
  font-size: 11px; color: var(--dim);
  max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card-sub {
  display: flex; gap: 10px; justify-content: space-between;
  font-size: 11.5px; color: var(--dim);
  margin: 3px 0 12px;
  overflow: hidden;
}
.card-sub span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub span:last-child { flex: none; color: var(--muted); }

.metric { margin-bottom: 9px; }
.metric.zero { display: none; }
.metric-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px; color: var(--muted); margin-bottom: 4px;
}
.metric-top b { color: var(--text); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.bar {
  height: 5px; border-radius: 4px; background: #17202c; overflow: hidden;
}
.bar > s {
  display: block; height: 100%; width: 0; border-radius: 4px;
  transition: width .55s cubic-bezier(.4, 0, .2, 1), background .3s;
  background: linear-gradient(90deg, #2f9e6f, var(--ok));
}
.bar > s.lv-warn { background: linear-gradient(90deg, #c98a12, var(--warn)); }
.bar > s.lv-bad { background: linear-gradient(90deg, #c1403f, var(--bad)); }
.bar > s.empty { background: #2a3546; }

.card-foot {
  display: flex; gap: 14px; align-items: center;
  font-size: 11.5px; color: var(--muted);
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}
.card-foot b { color: #c3d2e6; font-weight: 550; }
.card-foot .rx i, .card-foot .tx i { font-style: normal; margin-right: 2px; }
.card-foot .rx i { color: #38bdf8; }
.card-foot .tx i { color: #a78bfa; }
.card-foot .load { margin-left: auto; color: var(--dim); }

.spark { margin: 6px -15px -10px; height: 34px; color: var(--accent); }
.spark svg { display: block; width: 100%; height: 34px; }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center; padding: 70px 20px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 16px;
}
.empty h2 { font-size: 16px; color: var(--text); margin: 10px 0 6px; }
.empty p { margin: 0; font-size: 13px; }
.empty-icon { font-size: 34px; }

.page-foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 16px 22px 26px; font-size: 11.5px; color: #47576c;
}

/* ---------- 弹层 ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal-mask {
  position: absolute; inset: 0;
  background: rgba(3, 6, 10, .68);
  backdrop-filter: blur(3px);
  animation: fade .18s ease;
}
.modal-body {
  position: relative;
  width: 100%; max-width: 420px;
  max-height: calc(100vh - 60px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #131b26, #0c121a);
  box-shadow: 0 40px 90px -40px #000;
  padding: 20px;
  animation: rise .2s cubic-bezier(.2, .8, .3, 1);
}
.modal-body.wide { max-width: 940px; }
.modal-body h2 { margin: 0 0 6px; font-size: 17px; }
.modal-body > p { margin: 0 0 16px; font-size: 12.5px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99); } }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- 详情 ---------- */
.detail-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.detail-head h2 { font-size: 18px; margin: 0; }
.detail-head .dot { margin-top: 7px; }
.detail-head > div { flex: 1; min-width: 0; }
.detail-head .host { font-size: 12px; color: var(--dim); }
.icon {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; padding: 4px 6px; border-radius: 8px; line-height: 1;
}
.icon:hover { background: #1a2432; color: var(--text); }

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  overflow: hidden;
  margin-bottom: 16px;
}
.kv > div {
  background: #0d141d; padding: 9px 12px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.kv span { font-size: 11px; color: var(--dim); }
.kv b {
  font-size: 12.5px; font-weight: 550; color: #cfdcec;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 5px 11px; border-radius: 8px; font-size: 12px; cursor: pointer;
  transition: all .15s;
}
.tabs button:hover { color: var(--text); border-color: #2b3a4d; }
.tabs button.on { background: #16233a; border-color: #2f5fbf; color: #bcd4ff; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart {
  border: 1px solid var(--line-soft); border-radius: 11px;
  background: #0c131c; padding: 10px 12px 8px;
}
.chart-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px; color: var(--muted); margin-bottom: 4px;
}
.chart-head b { color: #cfdcec; font-variant-numeric: tabular-nums; }
.chart svg { display: block; width: 100%; height: 84px; overflow: visible; }
.chart-foot {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: #3f4d61; margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.legend { display: flex; gap: 10px; }
.legend i { font-style: normal; display: inline-flex; align-items: center; gap: 4px; }
.legend i::before {
  content: ""; width: 7px; height: 2px; border-radius: 2px; background: currentColor;
}
.detail-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft);
}

/* ---------- 安装命令块 ---------- */
.install { margin-top: 4px; }
.install h3 { font-size: 13px; margin: 14px 0 8px; color: #cfdcec; }
.code {
  position: relative;
  background: #060a10;
  border: 1px solid #1b2836;
  border-radius: 10px;
  padding: 11px 12px;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #9fd4b4;
  word-break: break-all;
  white-space: pre-wrap;
}
.code .copy {
  position: absolute; top: 7px; right: 7px;
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  background: #16202c; border: 1px solid var(--line); color: var(--muted);
  cursor: pointer;
}
.code .copy:hover { color: var(--text); }
.token {
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
  color: #ffd479; word-break: break-all;
}
.hint { font-size: 11.5px; color: var(--dim); margin-top: 8px; }
.hint code { color: #a8bdd6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 90;
  background: #16202c; border: 1px solid #2a3949; color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 18px 40px -18px #000;
  animation: rise .18s ease;
}
.toast.bad { border-color: #4a2430; color: #ffc9c9; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .summary { order: 3; width: 100%; flex: none; gap: 2px 14px; }
  .summary > span + span { border-left: none; padding-left: 0; margin-left: 0; }
  main { padding: 14px; }
  .grid { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
  .modal-body { padding: 16px; }
  .page-foot { padding: 12px 14px 22px; }
  .env { display: none; }
}
