:root {
  --brand: #006eff;
  --brand-hover: #0059d6;
  --brand-light: #e8f3ff;
  --bg: #f2f3f5;
  --card: #ffffff;
  --text: #1d2129;
  --text-2: #4e5969;
  --text-3: #86909c;
  --border: #e5e6eb;
  --border-light: #f2f3f5;
  --green: #00b42a;
  --green-bg: #e8ffea;
  --red: #f53f3f;
  --red-bg: #ffece8;
  --orange: #ff7d00;
  --orange-bg: #fff7e8;
  --purple: #722ed1;
  --radius: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }
input, select { font-family: inherit; font-size: 14px; }

/* ---------------- 登录页 ---------------- */
#login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef4ff 0%, #f7f9fc 45%, #eaf1ff 100%);
  z-index: 100;
}

.login-card {
  width: 400px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(29, 33, 41, .1);
  padding: 40px 36px 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.login-brand .logo-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
}

.login-brand h1 { font-size: 20px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.login-sub { color: var(--text-3); font-size: 13px; margin: 0 0 28px 0; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }

.input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(0, 110, 255, .1); }
.input::placeholder { color: #c0c4cc; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-danger { color: var(--red); border-color: #ffc9c2; background: #fff; }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-block { width: 100%; height: 38px; font-size: 14px; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-light); }

.login-error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
  margin-top: -6px;
  margin-bottom: 10px;
}

/* ---------------- 主框架 ---------------- */
#app { display: none; height: 100%; flex-direction: column; }
#app.ready { display: flex; }

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px 0 0;
  flex-shrink: 0;
  z-index: 20;
}

.topbar .brand {
  width: 220px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 20px;
  font-size: 16px;
  font-weight: 600;
}
.topbar .brand .logo-mark {
  width: 26px; height: 26px; border-radius: 6px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
}
.topbar .brand small { color: var(--text-3); font-size: 12px; font-weight: 400; margin-left: 2px; }

.topbar-center { flex: 1; display: flex; align-items: center; gap: 16px; padding-left: 20px; }
.search-box {
  width: 320px; height: 32px; border-radius: 16px; background: #f2f3f5;
  display: flex; align-items: center; padding: 0 12px; gap: 8px; color: var(--text-3);
}
.search-box input { border: 0; background: transparent; outline: none; flex: 1; font-size: 13px; }

.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--text-2); font-size: 13px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.topbar-right .icon-btn {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; cursor: pointer; color: var(--text-2);
}
.topbar-right .icon-btn:hover { background: var(--border-light); }

.layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 12px 0 20px;
  overflow-y: auto;
  flex-shrink: 0;
}
.nav-group { margin-bottom: 8px; }
.nav-title {
  font-size: 12px; color: var(--text-3); padding: 10px 20px 6px; letter-spacing: .5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 20px; cursor: pointer;
  color: var(--text-2); font-size: 14px;
  border-left: 2px solid transparent;
}
.nav-item svg { width: 16px; height: 16px; opacity: .75; }
.nav-item:hover { background: #f7f8fa; color: var(--text); }
.nav-item.active {
  background: var(--brand-light); color: var(--brand); font-weight: 500; border-left-color: var(--brand);
}
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 11px; background: var(--brand); color: #fff;
  border-radius: 8px; padding: 1px 6px; font-weight: 500;
}

.main { flex: 1; overflow-y: auto; padding: 16px 20px 40px; min-width: 0; }

.crumb { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }
.crumb a { color: var(--text-3); }
.crumb a:hover { color: var(--brand); }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.page-head h2 { font-size: 20px; margin: 0; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.page-head .sub { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border-light); gap: 12px;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head .hint { color: var(--text-3); font-size: 12px; font-weight: 400; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; align-items: center; gap: 16px;
}
.stat .ring { flex-shrink: 0; }
.stat .label { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.stat .value { font-size: 22px; font-weight: 600; line-height: 1.1; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--text-3); margin-left: 2px; }
.stat .foot { font-size: 12px; color: var(--text-3); margin-top: 6px; }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; }
.kv .k { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.kv .v { font-size: 14px; color: var(--text); word-break: break-all; }
.kv .v.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 13px; }

/* ---------------- 表格 ---------------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-weight: 400; color: var(--text-3); font-size: 12px;
  background: #fafbfc; padding: 10px 16px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fbff; }
tbody tr.clickable { cursor: pointer; }
.t-name { font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.t-name .id { color: var(--text-3); font-size: 12px; font-weight: 400; }
.t-actions { display: flex; gap: 6px; justify-content: flex-end; }
.muted { color: var(--text-3); }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: 2px; font-size: 12px;
  background: var(--border-light); color: var(--text-2);
  white-space: nowrap;
}
.tag-blue { background: var(--brand-light); color: var(--brand); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-orange { background: var(--orange-bg); color: var(--orange); }
.tag-red { background: var(--red-bg); color: var(--red); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #c9cdd4; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(0, 180, 42, .12); }
.dot.off { background: #c9cdd4; }

.bar { width: 90px; height: 4px; background: #f2f3f5; border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 2px; }
.bar.warn > i { background: var(--orange); }
.bar.danger > i { background: var(--red); }

/* ---------------- 选择卡片 ---------------- */
.choice-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.choice {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  cursor: pointer; background: #fff; transition: all .15s; position: relative;
}
.choice:hover { border-color: #a9c9ff; }
.choice.on { border-color: var(--brand); background: #f5f9ff; box-shadow: 0 0 0 1px var(--brand) inset; }
.choice .ico { width: 32px; height: 32px; border-radius: 6px; background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.choice h4 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.choice p { margin: 0; font-size: 12px; color: var(--text-3); line-height: 1.6; }
.choice .check {
  position: absolute; top: 12px; right: 12px; width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid var(--border); background: #fff;
}
.choice.on .check { border-color: var(--brand); background: var(--brand); }
.choice.on .check::after {
  content: ""; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* 镜像网格 */
.os-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.os-item {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
  cursor: pointer; display: flex; align-items: center; gap: 10px; background: #fff;
}
.os-item:hover { border-color: #a9c9ff; }
.os-item.on { border-color: var(--brand); background: #f5f9ff; }
.os-item .logo {
  width: 30px; height: 30px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.os-item .meta { min-width: 0; }
.os-item .meta b { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.os-item .meta span { font-size: 11px; color: var(--text-3); }

/* 规格 */
.spec-row { display: flex; gap: 12px; flex-wrap: wrap; }
.spec-box {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px;
  cursor: pointer; min-width: 120px; background: #fff;
}
.spec-box.on { border-color: var(--brand); background: #f5f9ff; }
.spec-box.off { opacity: .45; cursor: not-allowed; background: #fafafa; border-style: dashed; }
.spec-box.off span { color: #f53f3f; }
.spec-box b { display: block; font-size: 15px; }
.spec-box span { font-size: 12px; color: var(--text-3); }

.cap-line {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  background: #f2f7ff; border: 1px solid #d6e4ff; color: var(--text-2);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 13px;
}
.cap-line b { color: var(--brand); font-weight: 600; }
.cap-line i { color: var(--border); font-style: normal; }

.form-row { display: grid; grid-template-columns: 160px 1fr; gap: 16px; align-items: start; padding: 14px 0; border-bottom: 1px dashed var(--border-light); }
.form-row:last-child { border-bottom: 0; }
.form-row > label { font-size: 13px; color: var(--text-2); padding-top: 8px; }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.6; }

.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 应用市场 */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.app-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: #fff;
  display: flex; flex-direction: column; gap: 10px; transition: all .15s;
}
.app-card:hover { border-color: #a9c9ff; box-shadow: 0 2px 10px rgba(0, 110, 255, .06); }
.app-card .top { display: flex; align-items: center; gap: 10px; }
.app-card .logo { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.app-card h4 { margin: 0; font-size: 14px; font-weight: 600; }
.app-card .cat { font-size: 11px; color: var(--text-3); }
.app-card p { margin: 0; font-size: 12px; color: var(--text-3); line-height: 1.6; flex: 1; }
.app-card .foot { display: flex; align-items: center; justify-content: space-between; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 20px; }
.tab {
  padding: 12px 14px; font-size: 13px; color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--brand); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

/* 图表 */
.chart-wrap { padding: 0 8px 8px; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-3); padding: 0 12px 8px; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* 模态框 */
.mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 200;
  display: none; align-items: center; justify-content: center;
}
.mask.on { display: flex; }
.modal {
  width: 520px; max-width: calc(100vw - 32px); max-height: calc(100vh - 80px);
  background: #fff; border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
  display: flex; flex-direction: column;
}
.modal.wide { width: 720px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-head .x { cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 10px; }

/* 日志 */
.log-box {
  background: #1e1e1e; color: #d4d4d4; font-family: ui-monospace, Consolas, monospace;
  font-size: 12px; line-height: 1.7; border-radius: 4px; padding: 12px 14px;
  max-height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}
.log-box .ts { color: #6a737d; margin-right: 8px; }

/* toast */
#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: #1d2129; color: #fff; padding: 10px 18px; border-radius: 4px; font-size: 13px;
  opacity: 0; transition: all .2s; z-index: 999; pointer-events: none; max-width: 70vw;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #f53f3f; }

.empty { padding: 48px 0; text-align: center; color: var(--text-3); font-size: 13px; }
.empty .ico { font-size: 28px; margin-bottom: 10px; opacity: .5; }

.loading { padding: 40px; text-align: center; color: var(--text-3); font-size: 13px; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; background: #c9cdd4; border-radius: 10px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--orange-bg); border: 1px solid #ffe4ba; border-radius: var(--radius);
  font-size: 13px; color: #8a5a00; margin-bottom: 16px;
}
.banner.blue { background: var(--brand-light); border-color: #cfe4ff; color: #1d4f91; }

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .choice-row { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 180px; }
  .topbar .brand { width: 180px; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .choice-row { grid-template-columns: 1fr; }
  .search-box { display: none; }
  .form-row { grid-template-columns: 1fr; gap: 6px; }
}
