:root {
  --bg: #070d1c;
  --bg-2: #0a1224;
  --side: rgba(9, 15, 30, 0.82);
  --panel: rgba(15, 23, 44, 0.74);
  --panel-solid: #0d1526;
  --line: rgba(86, 120, 180, 0.16);
  --line-strong: rgba(96, 135, 200, 0.28);
  --text: #e8eefc;
  --muted: #8496b4;
  --dim: #63748f;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 背景光晕 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 480px at 92% -8%, rgba(37, 99, 235, 0.28), transparent 62%),
    radial-gradient(720px 420px at -6% 108%, rgba(14, 116, 233, 0.20), transparent 60%),
    radial-gradient(600px 320px at 40% 115%, rgba(56, 189, 248, 0.08), transparent 65%);
}

button, input, select, textarea { font-family: inherit; }

/* ================= 布局 ================= */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 208px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 20px 16px 18px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px; overflow: hidden; flex: 0 0 auto;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}
.brand-logo img { width: 100%; height: 100%; display: block; }
.brand-name { font-size: 14.5px; font-weight: 600; letter-spacing: .3px; }
.brand-sub { font-size: 10.5px; color: var(--dim); letter-spacing: .2px; }

.nav { display: flex; flex-direction: column; gap: 6px; padding: 6px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 80px; padding: 0 16px;
  background: transparent; border: 1px solid transparent; border-radius: 11px;
  color: #93a5c0; font-size: 13.5px; text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0.06));
  border-color: rgba(59, 130, 246, 0.28);
  color: #dbeafe;
}
.nav-item .ni {
  width: 19px; height: 19px; flex: 0 0 auto; opacity: .9;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}

.side-foot {
  margin-top: auto; padding: 14px 18px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--dim);
  display: flex; align-items: center; gap: 7px;
}

.main { padding: 26px 30px 44px; min-width: 0; }
.page.hidden { display: none; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.page-head h1 { margin: 0 0 5px; font-size: 25px; font-weight: 650; letter-spacing: .2px; }
.page-head .sub { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ================= 通用组件 ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--line-strong); background: rgba(28, 40, 68, 0.7); color: var(--text);
  height: 36px; padding: 0 14px; border-radius: 9px; cursor: pointer;
  font-size: 13px; transition: .15s; white-space: nowrap;
}
.btn:hover { background: rgba(38, 54, 88, 0.9); border-color: rgba(120, 160, 220, 0.4); }
.btn.primary {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border-color: rgba(96, 165, 250, 0.6);
  color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, 0.32);
}
.btn.primary:hover { background: linear-gradient(180deg, #4f8ef8, #2f6fef); }
.btn.danger { color: #ffb4b4; border-color: rgba(239, 68, 68, 0.35); }
.btn.danger:hover { background: rgba(64, 24, 24, 0.7); }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.plus { font-size: 14px; line-height: 1; margin-top: -1px; }

.icon-btn {
  border: none; background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 3px 8px; border-radius: 7px;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.chip {
  font-size: 12px; color: #a8bcd8; background: rgba(20, 32, 56, 0.7);
  border: 1px solid var(--line-strong); padding: 7px 13px; border-radius: 999px;
}
.muted { color: var(--muted); font-size: 12px; }
.right { text-align: right; }
.w40 { width: 38px; }
.w90 { width: 84px; }
.w100 { width: 96px; }
.w110 { width: 104px; }
.w120 { width: 116px; }
.w130 { width: 126px; }
.w150 { width: 148px; }
.w160 { width: 158px; }
.w180 { width: 176px; }
.w220 { width: 210px; }
.w260 { width: 250px; }

/* ================= 卡片 ================= */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(2, 8, 20, 0.35);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-title { display: flex; align-items: center; gap: 8px; }
.card-title h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card-title .ti {
  width: 16px; height: 16px;
  fill: none; stroke: #6f9be0; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.card-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 13px 18px; border-top: 1px solid var(--line);
}
.head-tools { display: flex; align-items: center; gap: 8px; }

/* ================= 统计卡 ================= */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }

.stat {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, rgba(26, 40, 72, 0.72), rgba(13, 21, 38, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px 16px;
}
.stat::after {
  content: "";
  position: absolute; right: -30px; bottom: -50px;
  width: 190px; height: 150px;
  background: radial-gradient(circle at 60% 60%, var(--tone), transparent 68%);
  opacity: .20; pointer-events: none;
}
.stat-top { display: flex; align-items: center; gap: 10px; }
.stat-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--tone-weak); color: var(--tone-text);
}
.stat-icon svg { width: 18px; height: 18px; fill: currentColor; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 29px; font-weight: 650; line-height: 1.2; margin: 9px 0 5px; letter-spacing: .5px; }
.stat-value small { font-size: 13px; color: var(--dim); font-weight: 500; margin-left: 3px; }
.stat-foot { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); position: relative; z-index: 1; }
.stat-foot.bad { color: #ff9b9b; }

.tone-blue   { --tone: #3b82f6; --tone-weak: rgba(59, 130, 246, .18); --tone-text: #9ec5ff; }
.tone-purple { --tone: #8b5cf6; --tone-weak: rgba(139, 92, 246, .18); --tone-text: #c4b5fd; }
.tone-teal   { --tone: #14b8a6; --tone-weak: rgba(20, 184, 166, .18); --tone-text: #7de3d6; }
.tone-orange { --tone: #f59e0b; --tone-weak: rgba(245, 158, 11, .18); --tone-text: #fcd34d; }

/* ================= 重复源警告 ================= */
.dup-warn {
  margin: -4px 0 2px; padding: 7px 10px;
  border: 1px solid rgba(239, 68, 68, .35); border-radius: 8px;
  background: rgba(239, 68, 68, .09);
  color: #ffb3b3; font-size: 11.5px; line-height: 1.5;
}
.dup-warn b { color: #ff8c8c; font-weight: 600; }
.field input.input-dup,
.field textarea.input-dup {
  border-color: rgba(239, 68, 68, .7) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}
.tbl .link.dup { color: #ff8c8c; }
.dup-badge {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 10.5px; color: #ffb3b3;
  background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .3);
  vertical-align: middle;
}

/* ================= 迷你统计 ================= */
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.mini-stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.mini-stat .k { font-size: 11.5px; color: var(--muted); }
.mini-stat .v { font-size: 22px; font-weight: 650; margin: 6px 0 4px; letter-spacing: .3px; }
.mini-stat .v small { font-size: 12px; color: var(--dim); font-weight: 500; margin-left: 4px; }
.mini-stat .s { font-size: 11px; color: var(--dim); }
.mini-stat.warn .v { color: #fcd34d; }

/* ================= 表格 ================= */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left; font-weight: 500; color: #7f90ab;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; font-size: 12px;
}
.tbl td {
  padding: 12px 16px; border-bottom: 1px solid rgba(86, 120, 180, 0.09);
  vertical-align: middle; color: #c8d5e8;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: rgba(70, 110, 180, 0.07); }
.tbl .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.tbl .link { color: #7cb2ff; text-decoration: none; }
.tbl .link:hover { text-decoration: underline; }
.tbl .nowrap { white-space: nowrap; }
.tbl .strong { color: #eaf1ff; font-weight: 550; }
.tbl .sub { color: var(--dim); font-size: 11.5px; }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ================= 徽标 ================= */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill .pdot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.running { background: rgba(34, 197, 94, .12); color: #6ee7a0; border-color: rgba(34, 197, 94, .28); }
.pill.waiting { background: rgba(245, 158, 11, .12); color: #fcd34d; border-color: rgba(245, 158, 11, .28); }
.pill.stopped { background: rgba(120, 140, 170, .12); color: #a9bad2; border-color: rgba(120, 140, 170, .26); }
.pill.error   { background: rgba(239, 68, 68, .12); color: #ffa8a8; border-color: rgba(239, 68, 68, .28); }
.pill.idle    { background: rgba(120, 140, 170, .12); color: #a9bad2; border-color: rgba(120, 140, 170, .26); }

.lv { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-family: ui-monospace, Menlo, monospace; }
.lv-info { background: rgba(59,130,246,.12); color: #93c5fd; }
.lv-warn { background: rgba(245,158,11,.14); color: #fcd34d; }
.lv-error { background: rgba(239,68,68,.14); color: #ffa8a8; }

.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #64748b; flex: 0 0 auto;
}
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(34, 197, 94, .12); }
.dot.err { background: var(--red); box-shadow: 0 0 0 3px rgba(239, 68, 68, .12); }
.dot.warn { background: var(--amber); box-shadow: 0 0 0 3px rgba(245, 158, 11, .12); }

/* ================= 表单 ================= */
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 14px 18px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); padding: 0; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 11.5px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(8, 14, 26, 0.85); color: var(--text);
  font-size: 12.5px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: rgba(59, 130, 246, .55); box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}
.field small { color: var(--dim); font-size: 11px; line-height: 1.5; }
.hidden { display: none !important; }

.search {
  background: rgba(8, 14, 26, 0.85); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 7px 11px; font-size: 12.5px; outline: none; width: 210px;
}
.search:focus { border-color: rgba(59, 130, 246, .55); }
.mini-select {
  background: rgba(8, 14, 26, 0.85); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 7px 9px; font-size: 12.5px; outline: none;
}

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: #b8c6d6; cursor: pointer; }
.check input { accent-color: var(--accent-2); }

.section-title {
  margin: 4px 0 0; font-size: 11px; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--dim);
  border-bottom: 1px dashed var(--line); padding-bottom: 6px;
}
.hint { margin: 0; padding: 0 18px 14px; font-size: 11.5px; color: var(--muted); }
.hint code { background: rgba(255, 255, 255, .06); padding: 1px 5px; border-radius: 4px; }
.inline-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ================= Tabs ================= */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  background: rgba(18, 28, 48, .7); border: 1px solid var(--line); color: #93a5c0;
  height: 30px; padding: 0 13px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, .25), rgba(59, 130, 246, .08));
  border-color: rgba(59, 130, 246, .42); color: #dbeafe;
}
.tab .cnt { opacity: .7; margin-left: 5px; }

.bulkbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .012);
}

/* ================= 弹窗 ================= */
.modal-mask {
  position: fixed; inset: 0; background: rgba(4, 9, 20, .74);
  backdrop-filter: blur(5px); display: none; align-items: center; justify-content: center;
  z-index: 60; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%; max-width: 560px; background: #0b1424;
  border: 1px solid var(--line-strong); border-radius: 16px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .6);
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal.wide { max-width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px 20px; overflow: auto; display: grid; gap: 13px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 13px 20px; border-top: 1px solid var(--line);
}
.deploy-status { font-size: 13px; color: #b8c6d6; }

/* ================= 日志 ================= */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 92vw);
  background: #060c18; border-left: 1px solid var(--line-strong);
  transform: translateX(102%); transition: transform .22s ease;
  display: flex; flex-direction: column; z-index: 70;
  box-shadow: -24px 0 60px rgba(0, 0, 0, .55);
}
.drawer.show { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.drawer-tools { display: flex; align-items: center; gap: 14px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }

.log-body {
  flex: 1; overflow: auto; margin: 0; padding: 14px 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.65; color: #b9cbe2;
  white-space: pre-wrap; word-break: break-all;
}
.log-body.small { max-height: 46vh; border: 1px solid var(--line); border-radius: 9px; background: #050a14; }

/* ================= Toast ================= */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px);
  background: #14243f; border: 1px solid var(--line-strong); color: var(--text);
  padding: 9px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 90;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(239, 68, 68, .45); color: #ffc0c0; }

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; }
  .brand { padding: 12px; }
  .nav { flex-direction: row; padding: 6px 8px; }
  .nav-item { min-height: 44px; padding: 0 12px; }
  .side-foot { display: none; }
  .main { padding: 18px; }
}
