:root {
  --bg: #0e1015;
  --bg-soft: #151922;
  --card: #1a1f2b;
  --card-hover: #212838;
  --border: #2a3142;
  --text: #e7ecf3;
  --text-dim: #9aa5b8;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --green: #2fbf71;
  --red: #f2555a;
  --amber: #f5a623;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1a2233 0%, var(--bg) 55%);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

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

/* 侧边栏 */
.sidebar {
  width: 216px; flex-shrink: 0;
  background: rgba(21, 25, 34, 0.9);
  border-right: 1px solid var(--border);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 700; color: #fff;
}
.brand .name { font-weight: 600; font-size: 15px; }
.brand .sub { font-size: 11px; color: var(--text-dim); }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; color: var(--text-dim); cursor: pointer;
  user-select: none; transition: all 0.15s ease; font-weight: 500;
}
.nav-item:hover { background: var(--card-hover); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(79,140,255,.18), rgba(124,92,255,.12));
  color: #fff; box-shadow: inset 0 0 0 1px rgba(79,140,255,.35);
}
.nav-item .ico { width: 18px; text-align: center; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { font-size: 11px; color: var(--text-dim); padding: 8px; line-height: 1.6; }
.sidebar .foot .dot { margin-right: 2px; }

/* 主区域 */
.main { flex: 1; padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 20px; font-weight: 650; }
.page-head .desc { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.page { display: none; }
.page.active { display: block; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 820px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

.metric .label { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; }
.metric .value { font-size: 24px; font-weight: 680; letter-spacing: .3px; }
.metric .sub { color: var(--text-dim); font-size: 12px; margin-top: 6px; }
.bar { height: 6px; border-radius: 5px; background: #2a3142; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }
.bar.warn > i { background: linear-gradient(90deg, #f5a623, #f2555a); }

.section-title { font-size: 14px; font-weight: 600; margin: 22px 0 12px; }
.muted { color: var(--text-dim); }

/* 按钮 */
.btn {
  border: 1px solid var(--border); background: var(--card-hover); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13px;
  font-weight: 550; transition: all .15s ease; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.danger { background: rgba(242,85,90,.12); border-color: rgba(242,85,90,.4); color: #ff8a8e; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }

/* 表单 */
input, select, textarea {
  background: #11151d; color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; font-size: 13px; width: 100%;
  font-family: inherit; outline: none; transition: border .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row > * { flex: 1; min-width: 180px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; }
.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; }
.checkbox input { width: auto; }

/* 表格 */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #141924; color: var(--text-dim); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
tbody tr:hover { background: rgba(79,140,255,.05); }
tbody tr:last-child td { border-bottom: none; }
td.wrap { white-space: normal; max-width: 380px; }
.empty { padding: 36px; text-align: center; color: var(--text-dim); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.green { background: rgba(47,191,113,.15); color: #58d38c; }
.badge.red { background: rgba(242,85,90,.15); color: #ff8a8e; }
.badge.gray { background: rgba(154,165,184,.14); color: var(--text-dim); }
.badge.blue { background: rgba(79,140,255,.15); color: #7fb0ff; }
.badge.amber { background: rgba(245,166,35,.15); color: #f7bb5c; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }

/* 模态 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,7,11,.7); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal.lg { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .x { cursor: pointer; color: var(--text-dim); font-size: 20px; line-height: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); }

/* 日志 / 代码 */
pre.log {
  background: #0b0e14; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; font-size: 12px; line-height: 1.55; color: #b9c4d4;
  max-height: 520px; overflow: auto; white-space: pre-wrap; word-break: break-all;
  font-family: "SF Mono", Menlo, Consolas, monospace; margin: 0;
}
textarea.code { min-height: 420px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; }

/* Toast */
#toast { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); min-width: 240px; max-width: 380px; animation: slideIn .2s ease; }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.hint { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 13px; }
.kv .k { color: var(--text-dim); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mono { font-family: "SF Mono", Menlo, Consolas, monospace; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; font-size: 13px; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 30px 28px; box-shadow: var(--shadow);
}
.login-card .logo {
  width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 20px;
}
.login-card h1 { font-size: 19px; margin: 0 0 6px; text-align: center; }
.login-card .sub { text-align: center; color: var(--text-dim); font-size: 12.5px; margin-bottom: 22px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.login-error { color: #ff8a8e; font-size: 12.5px; min-height: 18px; margin-top: 12px; text-align: center; }
