:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2230;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #388bfd;
  --accent-hover: #58a6ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { padding: 18px 20px; font-weight: 700; font-size: 16px; border-bottom: 1px solid var(--border); }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }
.nav { flex: 1; padding: 10px 0; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--muted); text-decoration: none; cursor: pointer;
  border-left: 2px solid transparent;
}
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.active { color: var(--text); border-left-color: var(--accent); background: var(--panel-2); }
.nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.sidebar-foot a { color: var(--accent); cursor: pointer; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }
.content { padding: 24px; max-width: 1200px; }

.grid { display: grid; gap: 16px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
}
.card h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .big { font-size: 28px; font-weight: 700; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.metric-row { display: flex; flex-wrap: wrap; gap: 22px; }
.metric { min-width: 92px; }
.metric .v { font-size: 22px; font-weight: 700; }
.metric .l { color: var(--muted); font-size: 12px; }

.channel-card .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.channel-card .name { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.channel-badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--border); color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--panel-2); }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.pill { font-size: 11px; padding: 2px 9px; border-radius: 20px; font-weight: 600; display: inline-block; }
.pill.green { background: rgba(63,185,80,.15); color: var(--green); }
.pill.yellow { background: rgba(210,153,34,.15); color: var(--yellow); }
.pill.red { background: rgba(248,81,73,.15); color: var(--red); }
.pill.gray { background: rgba(139,148,158,.15); color: var(--muted); }
.pill.blue { background: rgba(56,139,253,.15); color: var(--accent-hover); }
.pill.purple { background: rgba(188,140,255,.15); color: var(--purple); }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 6px; padding: 7px 14px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--red); border-color: rgba(248,81,73,.4); }
button.danger:hover { background: rgba(248,81,73,.12); }
button.sm { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  font: inherit; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 11px; width: 100%;
}
textarea { resize: vertical; min-height: 120px; font-family: ui-monospace, monospace; font-size: 12px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; margin-top: 12px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .spacer { flex: 1; }

.section-title { font-size: 15px; font-weight: 700; margin: 22px 0 12px; }

.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); width: 560px; max-width: 92vw; max-height: 88vh; overflow: auto; padding: 22px; }
.modal h2 { font-size: 17px; margin-bottom: 6px; }
.modal .muted { color: var(--muted); font-size: 12px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.toast { position: fixed; bottom: 22px; right: 22px; z-index: 40; display: flex; flex-direction: column; gap: 8px; }
.toast .t { padding: 11px 16px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); box-shadow: 0 4px 16px rgba(0,0,0,.4); max-width: 380px; }
.toast .t.ok { border-left: 3px solid var(--green); }
.toast .t.err { border-left: 3px solid var(--red); }

.empty { text-align: center; color: var(--muted); padding: 40px; }
.loading { text-align: center; color: var(--muted); padding: 40px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.bar-chart { width: 100%; height: 200px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.kbd { font-family: ui-monospace, monospace; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 12px; }
a.link { color: var(--accent-hover); cursor: pointer; text-decoration: none; }
.warn-banner { background: rgba(210,153,34,.12); border: 1px solid rgba(210,153,34,.4); color: var(--yellow); padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
