:root {
  --bg: #f1f1ee;
  --surface: #ffffff;
  --surface-2: #f8f8f5;
  --ink: #171716;
  --muted: #777772;
  --muted-2: #a4a49e;
  --line: #e3e3de;
  --line-strong: #cfcfc8;
  --sidebar: #171716;
  --sidebar-muted: #9e9e98;
  --green: #2f6f4e;
  --amber: #8a6a2f;
  --red: #8c3f3f;
  --radius: 18px;
  --shadow: 0 1px 0 rgba(23, 23, 22, .03), 0 12px 30px rgba(23, 23, 22, .04);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden, [hidden] { display: none !important; }
.mobile-only { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #ecece8;
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 34px;
  box-shadow: var(--shadow);
}
.login-title { font-size: 24px; font-weight: 720; letter-spacing: -.04em; margin-top: 18px; }
.login-subtitle { color: var(--muted); font-size: 13px; margin: 4px 0 28px; }
.login-card .input { margin: 8px 0 18px; }
.form-error { color: var(--red); font-size: 12px; margin-top: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--sidebar); color: #fff;
  font-weight: 750; font-size: 16px; letter-spacing: -.04em;
}
.brand-mark.large { width: 44px; height: 44px; border-radius: 14px; font-size: 20px; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex: 0 0 218px; background: var(--sidebar); color: #f4f4ef;
  min-height: 100vh; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 22px 14px 16px;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 680; letter-spacing: -.02em; }
.nav { display: grid; gap: 5px; }
.nav-item {
  width: 100%; border: 0; background: transparent; color: var(--sidebar-muted);
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px;
  text-align: left; font-size: 13px; transition: background .15s, color .15s;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.1); }
.nav-item.muted { color: #777772; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 10px; }
.status-line { display: flex; align-items: center; gap: 8px; color: var(--sidebar-muted); font-size: 11px; padding: 8px 12px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #8bbf9e; box-shadow: 0 0 0 3px rgba(139,191,158,.12); }
[data-icon] { width: 17px; height: 17px; display: inline-flex; flex: 0 0 17px; }
[data-icon] svg { width: 100%; height: 100%; }

.main { min-width: 0; flex: 1; }
.topbar {
  height: 74px; display: flex; align-items: center; gap: 16px;
  padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(241,241,238,.88);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(14px);
}
.page-title { font-size: 18px; font-weight: 700; letter-spacing: -.035em; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.view { padding: 28px 32px 44px; max-width: 1500px; margin: 0 auto; }
.icon-button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
}
.button {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 10px; font-size: 12px; font-weight: 620;
  transition: background .15s, border-color .15s, transform .15s;
}
.button:hover { border-color: #b4b4ad; }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.button.primary:hover { background: #2b2b29; }
.button.danger { color: var(--red); border-color: #e0c9c9; }
.button.small { padding: 6px 10px; font-size: 11px; border-radius: 8px; }
.button.full { width: 100%; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 13px; outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: #aaa9a2; background: #fff; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.field-label { display: block; color: var(--muted); font-size: 11px; font-weight: 620; margin: 14px 0 6px; }
.field-hint { color: var(--muted-2); font-size: 11px; margin-top: 6px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }

.grid { display: grid; gap: 16px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.two-col { grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-title { font-size: 13px; font-weight: 680; letter-spacing: -.01em; }
.card-meta { color: var(--muted); font-size: 11px; }
.stat-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 740; letter-spacing: -.06em; margin: 11px 0 7px; font-variant-numeric: tabular-nums; }
.stat-foot { color: var(--muted-2); font-size: 11px; }
.realm-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.realm-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--surface-2); }
.realm-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.realm-name { font-size: 12px; font-weight: 680; }
.realm-metric { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; padding: 5px 0; }
.realm-metric strong { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 3px 8px;
  font-size: 10px; font-weight: 650; white-space: nowrap;
}
.tag.cn { color: #514d42; background: #f5f1e8; border-color: #e6dfd1; }
.tag.intl { color: #4f5452; background: #eef2f0; border-color: #dce5e0; }
.tag.good { color: var(--green); background: #eef5f0; border-color: #dbe9df; }
.tag.warn { color: var(--amber); background: #f8f3e9; border-color: #eadfc9; }
.tag.bad { color: var(--red); background: #f8eeee; border-color: #ead6d6; }
.tag.neutral { color: var(--muted); }

.chart-card { min-height: 280px; }
.chart-wrap { position: relative; height: 210px; }
.chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.chart-empty { height: 210px; display: grid; place-items: center; color: var(--muted-2); font-size: 12px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-line { width: 18px; height: 2px; background: var(--ink); }
.legend-line.dashed { background: repeating-linear-gradient(to right, var(--muted) 0 3px, transparent 3px 6px); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .02em; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid #eeeeea; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfbf9; }
.table-title { font-weight: 650; font-size: 12px; }
.table-sub { color: var(--muted-2); font-size: 10px; margin-top: 3px; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted-2); font-size: 12px; }
.pill-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; gap: 2px; }
.segmented button { border: 0; background: transparent; color: var(--muted); font-size: 11px; padding: 6px 10px; border-radius: 7px; }
.segmented button.active { background: var(--ink); color: #fff; }
.search { width: 220px; max-width: 100%; }
.switch { position: relative; width: 34px; height: 20px; display: inline-block; flex: 0 0 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #d8d8d1; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.16); transition: .15s; }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(14px); }

.terminal {
  background: #151514; border: 1px solid #2a2a28; border-radius: 16px; padding: 16px;
  min-height: 320px; max-height: 560px; overflow: auto; color: #d8d8d2;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 11px; line-height: 1.65;
}
.term-line { display: grid; grid-template-columns: 78px 48px minmax(0, 1fr); gap: 9px; padding: 2px 0; }
.term-time { color: #6f6f69; }
.term-level { font-weight: 700; }
.term-level.INFO { color: #b9b9b1; }
.term-level.WARN { color: #d1b67a; }
.term-level.ERROR { color: #d99a9a; }
.term-msg { white-space: pre-wrap; word-break: break-word; }
.term-attrs { color: #8c8c84; margin-left: 6px; }
.term-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.term-actions .input { max-width: 220px; }

.account-avatar {
  width: 30px; height: 30px; border-radius: 10px; background: #e9e9e3; color: #55554f;
  display: grid; place-items: center; font-size: 11px; font-weight: 720; flex: 0 0 30px;
}
.account-cell { display: flex; align-items: center; gap: 9px; min-width: 170px; }
.credit { font-weight: 700; font-variant-numeric: tabular-nums; }
.credit.zero { color: var(--muted-2); }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.section-label { font-size: 11px; color: var(--muted); font-weight: 650; margin-bottom: 10px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.settings-card { min-height: 200px; }
.settings-card.wide { grid-column: span 2; }
.save-bar { display: flex; justify-content: flex-end; margin-top: 18px; gap: 8px; }
.notice { border: 1px solid var(--line); border-left: 3px solid var(--ink); background: var(--surface); padding: 12px 14px; border-radius: 10px; font-size: 11px; color: var(--muted); margin-bottom: 16px; }
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 100;
  background: var(--ink); color: #fff; border-radius: 11px; padding: 11px 15px;
  font-size: 12px; box-shadow: 0 14px 32px rgba(0,0,0,.18); max-width: 360px;
}
.modal-backdrop { position: fixed; inset: 0; background: rgba(23,23,22,.4); display: grid; place-items: center; padding: 22px; z-index: 80; }
.modal { width: min(480px, 100%); background: var(--surface); border-radius: 20px; padding: 24px; border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,.2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 15px; font-weight: 700; letter-spacing: -.03em; }
.modal-close { border: 0; background: transparent; font-size: 20px; color: var(--muted); }
.auth-url { word-break: break-all; font-size: 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px; margin: 12px 0; }
.progress { height: 5px; border-radius: 999px; background: #eeeeea; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ink); border-radius: inherit; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .mobile-only { display: grid !important; }
  .sidebar { position: fixed; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { width: 100%; }
  .topbar { padding: 0 16px; height: 64px; }
  .view { padding: 18px 16px 32px; }
  .stats-grid, .settings-grid, .form-grid, .realm-grid { grid-template-columns: 1fr; }
  .settings-card.wide, .form-grid .span-2 { grid-column: auto; }
  .page-title { font-size: 16px; }
  .top-actions .segmented { display: none; }
  .search { width: 100%; }
  .term-line { grid-template-columns: 64px 44px minmax(0,1fr); }
}
