:root {
  --bg: #0f1420;
  --panel: #161d2d;
  --panel-2: #1d2537;
  --line: #2a3448;
  --text: #e8edf7;
  --muted: #8d9ab3;
  --accent: #4f8cff;
  --accent-2: #38d39f;
  --warn: #ffb454;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #182036, #131a29);
  position: sticky; top: 0; z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #7a5cff);
  font-weight: 700; font-size: 20px;
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .5px; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.stat { color: var(--muted); font-size: 12px; margin-right: 4px; }

.layout { display: grid; grid-template-columns: 250px 1fr; gap: 0; min-height: calc(100vh - 71px); }

.sidebar {
  border-right: 1px solid var(--line); padding: 18px; position: sticky; top: 71px;
  height: calc(100vh - 71px); overflow: auto; background: var(--panel);
}
.sidebar h2 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; letter-spacing: 1px; }
.block { margin-bottom: 20px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 9px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13px;
}
.list li:hover { background: var(--panel-2); color: var(--text); }
.list li.active { background: rgba(79,140,255,.16); color: var(--text); font-weight: 600; }
.list li .n { color: var(--muted); font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: 3px 10px; border-radius: 999px; cursor: pointer; font-size: 12px;
}
.chip.active { border-color: var(--accent); color: var(--text); background: rgba(79,140,255,.14); }

.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type="search"], input[type="text"], input[type="password"], input:not([type]) {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #0f1523; color: var(--text); font-size: 13px;
}
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 6px; }

main { padding: 20px 22px 60px; }
.toolbar { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.live {
  background: rgba(56,211,159,.07); border: 1px solid rgba(56,211,159,.35);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
}
.live h3 { margin: 0 0 8px; font-size: 13px; color: var(--accent-2); }
.banner {
  background: rgba(79,140,255,.10); border: 1px solid rgba(79,140,255,.4);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px;
  font-size: 12.5px; color: #c9d9f5;
}
.live-list { display: flex; flex-wrap: wrap; gap: 8px; }
.live-item {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}
.live-item a { color: #b6f2da; text-decoration: none; }
.live-item a:hover { text-decoration: underline; }
.toolbar h2 { margin: 0; font-size: 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.card.running { border-color: rgba(56,211,159,.5); }
.card.error { border-color: rgba(255,107,107,.5); }
.card-head { display: flex; gap: 10px; align-items: flex-start; }
.index {
  min-width: 26px; height: 26px; border-radius: 8px; background: var(--panel-2);
  display: grid; place-items: center; font-size: 12px; color: var(--muted);
}
.card h3 { margin: 0; font-size: 14.5px; }
.card .en { color: var(--muted); font-size: 11px; }
.card .purpose { color: #c6d1e6; font-size: 12.5px; margin: 0; }
.card .path { color: var(--muted); font-family: Consolas, monospace; font-size: 10.5px; word-break: break-all; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.tag.k-kind { color: #9fd0ff; border-color: rgba(79,140,255,.4); }
.tag.k-free { color: var(--accent-2); border-color: rgba(56,211,159,.4); }
.tag.k-warn { color: var(--warn); border-color: rgba(255,180,84,.4); }
.tag.k-bad { color: var(--danger); border-color: rgba(255,107,107,.45); }

.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.btn {
  border: 1px solid var(--accent); background: rgba(79,140,255,.16); color: #dce8ff;
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
}
.btn:hover { background: rgba(79,140,255,.28); }
.btn.ghost { border-color: var(--line); background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.ok { border-color: rgba(56,211,159,.6); background: rgba(56,211,159,.16); color: #b6f2da; }
.btn.danger { border-color: rgba(255,107,107,.6); background: rgba(255,107,107,.12); color: #ffd3d3; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.state { font-size: 11.5px; }
.state.running { color: var(--accent-2); }
.state.error { color: var(--danger); }
.state.busy { color: var(--warn); }

.drawer-mask, .modal-mask { position: fixed; inset: 0; background: rgba(6,9,16,.6); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(680px, 92vw);
  background: var(--panel); border-left: 1px solid var(--line); z-index: 50;
  overflow: auto; padding: 22px;
}
.drawer h2 { margin: 0 0 4px; font-size: 18px; }
.drawer h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 20px 0 8px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv code, code.inline { font-family: Consolas, monospace; background: #0e1421; padding: 1px 6px; border-radius: 6px; font-size: 12px; }

pre.log {
  background: #0b101b; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-family: Consolas, monospace; font-size: 11.5px; color: #b9c6dd;
  max-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.modal {
  position: fixed; top: 8vh; left: 50%; transform: translateX(-50%);
  width: min(620px, 92vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px; z-index: 50; max-height: 84vh; overflow: auto;
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin: 10px 0; }
.missing { color: var(--danger); }
.ready { color: var(--accent-2); }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.muted { color: var(--muted); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
}
