:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1d212b;
  --line: #262c38;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;
  --orange: #fb923c;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(900px 300px at 80% -10%, rgba(96, 165, 250, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.page { max-width: 1180px; margin: 0 auto; padding: 18px 18px 40px; }
.hidden { display: none !important; }

/* header */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #0b0f19;
  background: linear-gradient(135deg, #60a5fa, #34d399);
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-on { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.7); }
.dot-off { background: var(--red); }

.alert {
  background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px;
}

/* cards */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px;
}
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.card-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.big.disk-big { font-size: 17px; }
.big { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meta { margin-top: 5px; color: var(--muted); font-size: 11.5px; word-break: break-all; }

/* panels */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 14px;
}
.panel h2 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.note { color: var(--muted); font-size: 11.5px; margin: 8px 0 0; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.chart-box h3 { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.chart-box canvas { width: 100%; height: 150px; background: #12151c; border: 1px solid var(--line); border-radius: 10px; }

/* services */
.svc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.svc {
  display: flex; align-items: center; gap: 10px;
  background: #12151c; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px;
}
.svc-icon { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.svc-icon.ok { background: var(--green); box-shadow: 0 0 7px rgba(52,211,153,.6); }
.svc-icon.bad { background: var(--red); box-shadow: 0 0 7px rgba(248,113,113,.6); }
.svc-main { flex: 1; min-width: 0; }
.svc-name { font-size: 13.5px; font-weight: 600; }
.svc-state { font-size: 11px; color: var(--muted); margin-top: 2px; }
.svc-state.ok { color: var(--green); }
.svc-state.bad { color: var(--red); }

/* process table */
.proc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.proc-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.proc-table td { padding: 6px 8px; border-bottom: 1px solid rgba(38,44,56,.55); font-variant-numeric: tabular-nums; }
.proc-table tr:last-child td { border-bottom: 0; }

/* api */
.api-locked p { color: var(--muted); font-size: 13px; }
#balance-form { display: flex; gap: 8px; max-width: 420px; }
#balance-form input {
  flex: 1; height: 38px; background: #12151c; border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 0 12px; outline: none;
}
#balance-form input:focus { border-color: var(--blue); }
#balance-form button {
  height: 38px; padding: 0 16px; border: 0; border-radius: 9px; cursor: pointer;
  background: var(--blue); color: #0b0f19; font-weight: 600;
}
.err { color: var(--red); font-size: 12.5px; min-height: 16px; }

.balance-cards { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.balance-card {
  background: #12151c; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; min-width: 150px;
}
.balance-card .label { color: var(--muted); font-size: 11.5px; }
.balance-card .amount { font-size: 19px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.usage-block h3 { font-size: 12.5px; color: var(--muted); font-weight: 500; margin: 0 0 8px; }
.usage-block canvas { width: 100%; height: 180px; background: #12151c; border: 1px solid var(--line); border-radius: 10px; }
.usage-totals { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.usage-totals b { color: var(--text); }

footer { text-align: center; color: #4a5160; font-size: 12px; margin-top: 18px; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .page { padding: 12px; }
}

/* portal nav */
.topbar { position: relative; }
.top-right { position: relative; }
.portal-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px;
  padding: 0 12px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
  font-size: 13px; transition: border-color .15s, background .15s;
}
.portal-btn:hover { border-color: var(--blue); background: #202634; }
.portal-btn svg { width: 16px; height: 16px; }
.portal-btn.on { border-color: var(--blue); background: #202634; }
.portal-menu {
  position: absolute; top: 46px; right: 0; z-index: 50;
  width: 280px; max-width: calc(100vw - 28px);
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
  overflow: hidden;
}
.portal-head {
  padding: 11px 14px 9px; font-size: 13px; font-weight: 700;
  border-bottom: 1px solid var(--line); color: var(--muted);
}
.portal-list { padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.portal-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 10px; border-radius: 10px; text-decoration: none;
  color: var(--text); transition: background .15s;
}
.portal-item:hover { background: #262c38; }
.portal-item.current { background: rgba(96,165,250,.12); }
.portal-badge {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: #12151c; border: 1px solid var(--line);
}
.portal-info { min-width: 0; }
.portal-name { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.portal-tag {
  font-size: 10px; color: var(--blue); border: 1px solid rgba(96,165,250,.4);
  padding: 1px 6px; border-radius: 20px; white-space: nowrap;
}
.portal-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ================= 右侧应用抽屉 ================= */
.page { margin-right: 300px; } /* 抽屉在右侧预留区内滑动，主内容不位移 */

.app-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 90;
  width: 300px; display: flex;
  background: linear-gradient(180deg, var(--panel2), #14171e);
  border-left: 1px solid var(--line);
  transform: translateX(0);
  transition: transform .22s ease;
  box-shadow: -8px 0 24px rgba(0,0,0,.28);
}
.app-drawer.collapsed { transform: translateX(248px); box-shadow: none; }
.app-drawer.collapsed .drawer-body { visibility: hidden; }
.app-drawer:not(.collapsed) .drawer-rail { display: none; }

.drawer-rail {
  width: 52px; flex: 0 0 52px; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between; padding: 12px 0;
  background: #101319; border-right: 1px solid var(--line);
  overflow: hidden;
}
.drawer-rail-label {
  writing-mode: vertical-lr;
  color: var(--muted); font-size: 11px; letter-spacing: 3px;
  white-space: nowrap;
}
.drawer-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 14px 12px; border-bottom: 1px solid var(--line);
}
.drawer-title { font-size: 15px; font-weight: 700; }
.drawer-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.drawer-toggle {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  background: #12151c; color: var(--muted); cursor: pointer;
  transition: color .15s, border-color .15s;
}
.drawer-toggle:hover { color: var(--text); border-color: var(--blue); }
.drawer-toggle svg { width: 16px; height: 16px; }
.drawer-body .portal-list { flex: 1; padding: 10px; overflow-y: auto; }
.drawer-foot {
  padding: 9px 12px; font-size: 10.5px; color: #4a5160;
  border-top: 1px solid var(--line); text-align: center;
}
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.45); backdrop-filter: blur(1px);
}

@media (max-width: 1023px) {
  body.drawer-open .page,
  body.drawer-collapsed .page,
  .page { margin-right: 0; }
  .app-drawer { box-shadow: -8px 0 28px rgba(0,0,0,.4); }
  .drawer-rail-label { display: none; }
}
