:root {
  --bg: #080b12;
  --panel: rgba(17, 23, 36, .78);
  --panel-strong: #111827;
  --line: rgba(148, 163, 184, .16);
  --text: #e5edf8;
  --muted: #8b9bb4;
  --accent: #7dd3fc;
  --accent-2: #a78bfa;
  --good: #34d399;
  --danger: #fb7185;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(56, 189, 248, .13), transparent 32rem),
    radial-gradient(circle at 85% 10%, rgba(167, 139, 250, .12), transparent 30rem),
    linear-gradient(180deg, #080b12 0%, #0a0f1a 100%);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.muted { color: var(--muted); }

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
}

.brand-mark {
  position: relative;
  width: 48px;
  height: 48px;
  margin-bottom: 24px;
}

.brand-mark span {
  position: absolute;
  display: block;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(125, 211, 252, .8);
  border-radius: 8px;
  background: rgba(125, 211, 252, .08);
}

.brand-mark span:nth-child(1) { top: 0; left: 12px; }
.brand-mark span:nth-child(2) { left: 0; bottom: 0; }
.brand-mark span:nth-child(3) { right: 0; bottom: 0; }

.brand-mark.small {
  width: 28px;
  height: 28px;
  margin: 0;
  transform: scale(.72);
  transform-origin: left center;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 24px 72px;
}

.login-page-footer {
  position: fixed;
  right: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 0;
  z-index: 2;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.login-shell { width: min(100%, 420px); }

.login-card {
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(20, 29, 46, .92), rgba(10, 15, 26, .9));
  box-shadow: 0 32px 80px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255,255,255,.04);
  backdrop-filter: blur(18px);
}

.login-card h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -.04em;
}

.login-card > .muted { margin: 12px 0 28px; font-size: 14px; }

.login-form { display: grid; gap: 16px; }

.login-form label { display: grid; gap: 8px; }

.login-form label span {
  color: #c9d5e7;
  font-size: 13px;
  font-weight: 600;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: rgba(3, 7, 14, .55);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  transition: border-color .16s, box-shadow .16s;
}

input:focus {
  border-color: rgba(125, 211, 252, .7);
  box-shadow: 0 0 0 4px rgba(125, 211, 252, .08);
}

.primary-button, .ghost-button {
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: transform .16s, filter .16s, border-color .16s;
}

.primary-button {
  margin-top: 6px;
  border: 0;
  border-radius: 12px;
  padding: 14px 16px;
  color: #06121c;
  background: linear-gradient(135deg, #a5f3fc, #7dd3fc 45%, #a78bfa);
}

.primary-button:hover { filter: brightness(1.06); transform: translateY(-1px); }

.alert {
  margin-bottom: 18px;
  border: 1px solid rgba(251, 113, 133, .32);
  border-radius: 12px;
  background: rgba(251, 113, 133, .08);
  color: #fecdd3;
  padding: 12px 14px;
  font-size: 13px;
}

.login-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 12px;
}

.foot-sep { opacity: .45; }

.icp-link {
  color: var(--muted);
  text-decoration: none;
}

.icp-link:hover { color: var(--text); text-decoration: underline; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--good);
  box-shadow: 0 0 12px rgba(52, 211, 153, .8);
  flex: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 12, 20, .55);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 13px; letter-spacing: .14em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .08em; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: #cbd5e1;
  font-size: 12px;
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 8px 13px;
}

.ghost-button:hover { border-color: rgba(125, 211, 252, .5); color: var(--text); }

.dashboard { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 40px; }

.hero { max-width: 720px; margin-bottom: 34px; }

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.04;
  letter-spacing: -.055em;
}

.hero .muted { font-size: 15px; line-height: 1.7; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 52px;
}

.stat-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
}

.stat-label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.stat-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; letter-spacing: -.02em; }
.stat-card small { display: block; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.section-heading .muted { font-size: 12px; }

.apps-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.app-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(22, 31, 49, .8), rgba(12, 18, 30, .76));
  padding: 20px;
}

.app-card > div:nth-child(2) { min-width: 0; flex: 1; }
.app-card h3 { margin: 0 0 6px; font-size: 16px; }
.app-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.app-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
  color: #04121d;
  font-weight: 800;
  font-size: 18px;
}

.piweb-icon { background: linear-gradient(135deg, #a5f3fc, #38bdf8); }
.hermes-icon { background: linear-gradient(135deg, #ddd6fe, #a78bfa); }
.files-icon { background: linear-gradient(135deg, #bbf7d0, #34d399); }
.monitor-icon { background: linear-gradient(135deg, #fde68a, #fbbf24); }

.badge {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 10px;
}

.app-card.disabled { opacity: .72; }

.footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  border-top: 1px solid var(--line);
  padding: 22px 0 30px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 820px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .apps-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .login-card { padding: 30px 24px; }
  .topbar { padding: 16px 20px; }
  .user-chip { display: none; }
  .dashboard { padding-top: 36px; }
  .stats-grid { gap: 10px; margin-bottom: 36px; }
  .stat-card { padding: 14px; }
  .stat-card strong { font-size: 17px; }
  .section-heading { align-items: start; flex-direction: column; gap: 6px; }
  .app-card { min-height: 112px; padding: 16px; }
}

/* 可点击的应用卡片 */
a.app-link { color: inherit; text-decoration: none; transition: border-color .15s ease, transform .15s ease; }
a.app-link:hover { border-color: #4f7cff; transform: translateY(-1px); }
a.app-link:focus-visible { outline: 2px solid #4f7cff; outline-offset: 2px; }
.badge-live { color: #04121d; border-color: transparent; font-weight: 700;
  background: linear-gradient(135deg, #bbf7d0, #34d399); }

/* 系统监控 */
.monitor-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 34px; }
.monitor-card {
  display: flex; flex-direction: column; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 18px;
}
.monitor-label { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.monitor-card strong { font-size: 26px; letter-spacing: -.02em; }
.monitor-card small { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 6px; border-radius: 999px; background: rgba(148, 163, 184, .16); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; transition: width .4s ease;
  background: linear-gradient(90deg, #38bdf8, #7dd3fc); }
.bar-fill.warn { background: linear-gradient(90deg, #fbbf24, #fde68a); }
.bar-fill.danger { background: linear-gradient(90deg, #fb7185, #fda4af); }
.bar-fill.net { background: linear-gradient(90deg, #a78bfa, #c4b5fd); }
.monitor-table { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.monitor-row { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 18px; font-size: 13px; border-bottom: 1px solid var(--line); }
.monitor-row:last-child { border-bottom: none; }
.monitor-row .row-key { color: var(--text); font-variant-numeric: tabular-nums; }
.state { font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.state-ok { color: #04121d; border-color: transparent; font-weight: 700;
  background: linear-gradient(135deg, #bbf7d0, #34d399); }
.state-bad { color: #fff; border-color: transparent; font-weight: 700;
  background: linear-gradient(135deg, #fb7185, #f43f5e); }
@media (max-width: 820px) { .monitor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .monitor-grid { grid-template-columns: 1fr; } .monitor-card strong { font-size: 22px; } }
