:root {
  --bg: #0b0e14;
  --bg-2: #111622;
  --panel: #151b28;
  --panel-2: #1a2130;
  --panel-3: #212a3b;
  --border: #262f41;
  --border-2: #333e54;
  --text: #e8eef7;
  --muted: #8593a8;
  --accent: #4c8dff;
  --accent-2: #2f6fe4;
  --green: #35c26b;
  --red: #f0553f;
  --yellow: #e0a534;
  --violet: #8b6cf0;
  --radius: 12px;
  --radius-sm: 9px;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ------------------------------ 登录 ------------------------------ */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 500px at 50% -10%, #17233b, var(--bg));
  padding: 20px;
  z-index: 200;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.login-card .logo { justify-content: center; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.login-hint { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 0; }

/* ------------------------------ 布局 ------------------------------ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 50;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 17px; letter-spacing: .3px;
  padding: 20px 22px;
}
.logo-lg { font-size: 22px; }
.logo .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: linear-gradient(135deg, #4c8dff, #35c26b);
  box-shadow: 0 0 12px rgba(76,141,255,.9);
}

.nav { flex: 1; padding: 6px 12px; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(76,141,255,.18), rgba(76,141,255,.04));
  color: #cfe0ff;
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--border); }
.ver { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(11,14,20,.8);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 40;
}
.titles { flex: 1; min-width: 0; }
.titles h1 { margin: 0; font-size: 19px; font-weight: 650; }
.titles .muted { margin: 1px 0 0; font-size: 12.5px; }
.topbar-actions { display: flex; gap: 10px; }

.content { padding: 24px 26px 60px; max-width: 1440px; width: 100%; }
.page { display: none; animation: fade .18s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------ 组件 ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 13.5px; font-weight: 550;
  cursor: pointer; transition: all .15s; white-space: nowrap;
  font-family: inherit;
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.lg { padding: 12px 18px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.danger { color: #ff8b7a; }
.btn.danger:hover { border-color: var(--red); color: #ff6b57; background: rgba(240,85,63,.08); }
.btn svg { width: 15px; height: 15px; }

.icon-btn {
  background: transparent; border: none; color: var(--muted);
  padding: 6px; border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 620; }
.link { color: var(--accent); font-size: 13px; }
.link:hover { text-decoration: underline; }

.field { margin-bottom: 15px; display: flex; flex-direction: column; gap: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { font-size: 12.5px; color: var(--muted); font-weight: 500; }

input, select, textarea {
  width: 100%; background: var(--bg);
  border: 1px solid var(--border-2); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 13.5px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76,141,255,.15);
}
textarea { resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

.notice {
  background: rgba(76,141,255,.08);
  border: 1px solid rgba(76,141,255,.25);
  color: #a9c6ff; border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: 12.5px; margin-bottom: 16px;
}

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border-2); color: var(--muted);
  background: var(--panel-2);
}
.badge.running, .badge.deployed { color: #6ee79b; border-color: rgba(53,194,107,.35); background: rgba(53,194,107,.1); }
.badge.failed { color: #ff8b7a; border-color: rgba(240,85,63,.35); background: rgba(240,85,63,.1); }
.badge.deploying { color: #f0c674; border-color: rgba(224,165,52,.35); background: rgba(224,165,52,.1); }
.badge.removed { color: var(--muted); }
.badge.pending { color: #a9c6ff; border-color: rgba(76,141,255,.35); background: rgba(76,141,255,.1); }

/* 统计卡 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: flex; align-items: center; gap: 14px;
}
.stat-ico {
  width: 44px; height: 44px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
}
.stat-ico.blue { background: rgba(76,141,255,.14); color: #6ea8ff; }
.stat-ico.green { background: rgba(53,194,107,.14); color: #5fd98c; }
.stat-ico.red { background: rgba(240,85,63,.14); color: #ff8b7a; }
.stat-ico.violet { background: rgba(139,108,240,.14); color: #ac96f7; }
.stat-num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 12.5px; }

/* 表格 */
.table-wrap { overflow-x: auto; margin: -4px; padding: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 14px; }
th {
  color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
td.actions-cell { text-align: right; white-space: nowrap; }
td .cell-title { font-weight: 600; }
td .cell-sub { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.row-actions { display: inline-flex; gap: 7px; justify-content: flex-end; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state svg { width: 36px; height: 36px; margin: 0 auto 10px; opacity: .4; }

.chip {
  background: var(--panel-2); border: 1px solid var(--border-2); color: var(--muted);
  padding: 5px 13px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  font-family: inherit;
}
.chip.active { color: #fff; border-color: var(--accent); background: rgba(76,141,255,.15); }

/* 部署页 */
.deploy-grid { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 18px; align-items: start; }
.terminal-card { display: flex; flex-direction: column; }
.terminal {
  background: #05070c; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 15px;
  height: 440px; overflow: auto; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
  color: #9db0c8;
}
.result { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.result input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.qr { margin-top: 14px; display: flex; justify-content: center; }
.qr img { background: #fff; padding: 10px; border-radius: 10px; width: 172px; height: 172px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(4,7,12,.72);
  backdrop-filter: blur(3px); display: flex; align-items: flex-start;
  justify-content: center; padding: 6vh 20px 20px; z-index: 150;
  animation: fade .15s ease; overflow: auto;
}
.modal {
  background: var(--panel); border: 1px solid var(--border-2);
  border-radius: 14px; width: 100%; max-width: 540px;
  box-shadow: 0 30px 70px rgba(0,0,0,.6);
  animation: pop .16s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
}
.modal-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(24px);
  background: var(--panel-3); border: 1px solid var(--border-2);
  color: var(--text); padding: 11px 20px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all .22s;
  z-index: 400; max-width: 84vw; box-shadow: 0 12px 30px rgba(0,0,0,.5);
  font-size: 13.5px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); }
.toast.ok { border-color: var(--green); }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.only-mobile { display: none; }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .deploy-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .only-mobile { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.6);
  }
  .sidebar.open { transform: none; }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 12px 16px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .titles h1 { font-size: 17px; }
}
