:root {
  --bg: #0b0f17;
  --bg2: #111827;
  --bg3: #182133;
  --panel: #131c2c;
  --border: #22304a;
  --border2: #2c3c5a;
  --text: #e6edf7;
  --text-dim: #8fa0ba;
  --text-faint: #5f7290;
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --purple: #a78bfa;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

.app { display: flex; height: 100vh; overflow: hidden; }

/* 侧边栏 */
.sidebar {
  width: 220px; min-width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.brand-logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff;
}
.brand-name { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-dim); }

.nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-dim); font-size: 14px;
  transition: all .15s;
}
.nav-item .ico { width: 18px; text-align: center; opacity: .8; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(59,130,246,.18), rgba(59,130,246,.04)); color: var(--accent2); border-left: 2px solid var(--accent); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.sidebar-stat { color: var(--text-faint); font-size: 12px; }

/* 顶栏 */
.topbar {
  height: 56px; min-height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--bg2);
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-hint { color: var(--text-faint); font-size: 12px; }

/* 通用 */
.content { flex: 1; overflow-y: auto; padding: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-title .sub { color: var(--text-faint); font-size: 12px; font-weight: 400; margin-left: 6px; }
.card-desc { color: var(--text-dim); font-size: 12px; margin-bottom: 14px; line-height: 1.7; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  font-size: 13px; border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text);
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2f6fd8; }
.btn-green { background: var(--green); border-color: var(--green); color: #052e12; }
.btn-red { background: transparent; border-color: var(--red); color: var(--red); }
.btn-red:hover { background: rgba(239,68,68,.12); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* 统计卡片 */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
}
.stat-label { color: var(--text-dim); font-size: 12px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-value .unit { font-size: 13px; color: var(--text-dim); font-weight: 400; margin-left: 3px; }
.stat-value.green { color: var(--green); }
.stat-value.blue { color: var(--accent2); }
.stat-value.red { color: var(--red); }
.stat-value.amber { color: var(--amber); }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: rgba(59,130,246,.05); }
tbody tr:last-child td { border-bottom: none; }
.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; color: var(--accent2); }
.token-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pending { color: var(--text-dim); background: rgba(143,160,186,.12); }
.badge.running { color: var(--accent2); background: rgba(59,130,246,.12); }
.badge.success { color: var(--green); background: rgba(34,197,94,.12); }
.badge.failed { color: var(--red); background: rgba(239,68,68,.12); }
.badge.unused { color: var(--green); background: rgba(34,197,94,.12); }
.badge.used { color: var(--text-faint); background: rgba(95,114,144,.15); }
.badge.online { color: var(--green); background: rgba(34,197,94,.12); }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; color: var(--text-dim); font-size: 13px; }

/* 表单 */
.form-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; align-items: flex-start; }
.form-label { width: 100px; color: var(--text-dim); font-size: 13px; flex-shrink: 0; padding-top: 9px; }
.form-input {
  flex: 1; min-width: 200px; padding: 9px 12px; border-radius: 8px;
  background: var(--bg3); border: 1px solid var(--border2); color: var(--text);
  font-family: inherit; font-size: 13px;
}
.form-input:focus { outline: none; border-color: var(--accent); }
textarea.form-input { min-height: 140px; resize: vertical; font-family: "Cascadia Code", Consolas, monospace; line-height: 1.7; }

/* 日志 */
.log-box {
  background: #0a0e16; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font-family: "Cascadia Code", Consolas, monospace; font-size: 12px;
  height: 340px; overflow-y: auto; line-height: 1.7; color: #b8c4d8;
}
.log-line { word-break: break-all; }
.log-line .ok { color: var(--green); }
.log-line .fail { color: var(--red); }
.log-line .key { color: var(--accent2); }
.log-line .t { color: var(--text-faint); }

/* 进度 */
.progress-wrap { display: flex; align-items: center; gap: 12px; }
.progress-bar { flex: 1; height: 10px; background: var(--bg3); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #7c3aed); border-radius: 6px; transition: width .5s; }
.progress-num { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

/* toast / modal */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--border2); border-radius: 10px;
  padding: 10px 18px; font-size: 13px; z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .25s; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 150;
  display: flex; align-items: center; justify-content: center;
}
.modal-mask[hidden] { display: none !important; }
.modal {
  background: var(--panel); border: 1px solid var(--border2); border-radius: 14px;
  padding: 22px; width: 600px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; font-size: 16px; }
.modal-wide { width: 760px; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.running { background: var(--green); animation: pulse 1.2s infinite; }
.status-dot.stopped { background: var(--text-faint); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.empty { text-align: center; color: var(--text-faint); padding: 40px 0; font-size: 13px; }

@media (max-width: 900px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 64px; min-width: 64px; }
  .brand-text { display: none; }
  .nav-item { font-size: 0; justify-content: center; }
  .nav-item .ico { font-size: 18px; }
  .sidebar-stat { display: none; }
}
