:root {
  --bg: #0b1020;
  --bg-soft: #121933;
  --card: #161e3a;
  --card-2: #1c2547;
  --line: #26304f;
  --text: #eef2ff;
  --muted: #93a0c4;
  --accent: #5b8cff;
  --accent-2: #7c5bff;
  --ok: #35d07f;
  --warn: #ffb02e;
  --bad: #ff5c7a;
  --radius: 16px;
  --pad: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

h1, h2 { margin: 0; font-weight: 650; letter-spacing: .01em; }
h2 { font-size: 17px; margin: 18px 2px 10px; }
p { margin: 0; }

.muted { color: var(--muted); }
.tiny { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.error { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 4px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(360px, 100%);
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 22px;
  display: grid;
  gap: 12px;
  text-align: center;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .55);
}
.brand-mark {
  width: 54px; height: 54px;
  margin: 0 auto 4px;
  display: grid; place-items: center;
  border-radius: 16px;
  font-size: 26px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px -8px var(--accent);
}
.brand-mark.small { width: 38px; height: 38px; font-size: 18px; border-radius: 12px; margin: 0; }

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1428;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
input:focus { border-color: var(--accent); }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform .06s ease, filter .15s ease;
}
.btn:active { transform: scale(.975); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 10px 22px -10px var(--accent);
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.full { width: 100%; }

/* ---------- 布局 ---------- */
.shell { display: block; min-height: 100dvh; }

.sidebar { display: none; }

.main {
  padding: calc(var(--pad) + env(safe-area-inset-top)) var(--pad)
           calc(84px + env(safe-area-inset-bottom));
  max-width: 980px;
  margin: 0 auto;
}

.tab { display: none; }
.tab.active { display: block; }

/* 卡片 */
.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.cards > .card:first-child { grid-column: 1 / -1; }
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 6px;
}
.card-label { color: var(--muted); font-size: 12.5px; }
.big { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; }
.status-line { display: flex; align-items: center; gap: 9px; font-size: 19px; }
.dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(147, 160, 196, .15);
}
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(53, 208, 127, .18); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px rgba(255, 92, 122, .18); }

/* 部署 */
.deploy-card { margin-top: 12px; gap: 12px; }
.deploy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.console {
  margin: 0;
  background: #080d1c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  height: 180px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: #b9c6ea;
  white-space: pre-wrap;
  word-break: break-word;
}
.console .ok { color: var(--ok); }
.console .bad { color: var(--bad); }
.console .dim { color: var(--muted); }

/* 文件列表 */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.file-list, .list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.file-row, .list li.row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.file-main { flex: 1; min-width: 0; }
.file-name {
  display: block;
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta { color: var(--muted); font-size: 12px; }
.icon-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 15px;
}
.icon-btn.danger { color: var(--bad); }
.icon-btn:active { transform: scale(.94); }

/* 移动端底部导航 */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(11, 16, 32, .88);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 0;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
}
.tabbar-btn.active { color: var(--text); background: var(--card-2); }

/* 编辑器 */
.editor {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.editor-head .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-actions { display: flex; gap: 8px; }
#editor-body {
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  resize: none;
  padding: 14px;
  background: #080d1c;
  color: #dbe4ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  tab-size: 2;
}
.editor-foot {
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}

/* 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: #1d2748;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: 88vw;
  text-align: center;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: var(--bad); }

/* ---------- 桌面 ---------- */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 16px;
    border-right: 1px solid var(--line);
    background: rgba(18, 25, 51, .6);
    position: sticky;
    top: 0;
    height: 100dvh;
  }
  .side-brand { display: flex; align-items: center; gap: 10px; }
  .side-brand strong { display: block; font-size: 14.5px; }
  .nav { display: grid; gap: 6px; }
  .nav-btn {
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
  }
  .nav-btn.active {
    color: var(--text);
    background: var(--card-2);
    border-color: var(--line);
  }
  .side-link {
    margin-top: auto;
    color: var(--muted);
    text-decoration: none;
    font-size: 13.5px;
    padding: 8px 2px;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
  }
  .side-link.danger { margin-top: 0; color: var(--bad); }
  .tabbar { display: none; }
  .main { padding: 28px 32px 40px; width: 100%; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cards > .card:first-child { grid-column: auto; }
  .console { height: 240px; }
  .toast { bottom: 32px; }
}
