:root {
  --primary: #2456c4;
  --primary-dark: #1a429e;
  --primary-light: #eaf0fb;
  --danger: #d64541;
  --success: #2e9e5b;
  --bg: #f2f4f8;
  --card: #ffffff;
  --border: #dde3ee;
  --text: #2b3445;
  --muted: #7b879b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }

/* ---------- 顶部导航 ---------- */
.navbar {
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  color: #fff; display: flex; align-items: center; gap: 8px;
  padding: 0 24px; height: 52px; box-shadow: 0 2px 8px rgba(0,0,0,.12);
  position: sticky; top: 0; z-index: 50;
}
.navbar .brand { font-size: 17px; font-weight: 700; margin-right: 24px; display:flex; align-items:center; gap:8px;}
.navbar a.nav-link {
  color: rgba(255,255,255,.85); padding: 6px 14px; border-radius: 6px; font-size: 14px;
}
.navbar a.nav-link:hover { background: rgba(255,255,255,.14); color: #fff; }
.navbar a.nav-link.active { background: rgba(255,255,255,.22); color: #fff; font-weight: 600; }
.navbar .spacer { flex: 1; }
.navbar .who { color: rgba(255,255,255,.9); font-size: 13px; margin-right: 8px; }
.navbar .btn-exit { color:#fff; background:rgba(255,255,255,.16); border:none; padding:6px 12px; border-radius:6px;
  cursor:pointer; text-decoration:none; display:inline-block; }
.navbar .btn-exit:hover { background:rgba(255,255,255,.28); }

.container { max-width: 1240px; margin: 20px auto; padding: 0 20px; }
.page-title { font-size: 20px; font-weight: 700; margin: 6px 0 16px; display:flex; align-items:center; gap:10px;}

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: 10px; border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(30,50,90,.06); padding: 18px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px){ .grid2{ grid-template-columns: 1fr; } }

/* ---------- 表单 ---------- */
label.f { display:block; font-weight:600; margin: 12px 0 4px; font-size: 13px; }
label.f .hint { color: var(--muted); font-weight: 400; font-size: 12px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(36,86,196,.12); }
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  display:inline-flex; align-items:center; gap:6px; border:none; cursor:pointer;
  padding: 9px 18px; border-radius: 7px; font-size: 14px; font-weight: 600;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn.green { background: var(--success); } .btn.green:hover{ background:#237a46; }
.btn.gray { background: #e6eaf2; color: var(--text); } .btn.gray:hover{ background:#d8deea;}
.btn.red { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn:disabled { opacity:.5; cursor:not-allowed; }

/* ---------- 表格 ---------- */
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; font-size: 12.5px; color: var(--muted); padding: 9px 8px; border-bottom: 2px solid var(--border); white-space: nowrap; }
table.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:hover td { background: #f7f9fd; }
.tag { display:inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; background: var(--primary-light); color: var(--primary); }
.tag.green { background:#e3f5ea; color: var(--success); }
.tag.gray { background:#eceff4; color: var(--muted); }
.tag.red { background:#fdeaea; color: var(--danger); }
.dot { display:inline-block; width:8px; height:8px; border-radius:50%; }
.dot.green{ background: var(--success);} .dot.gray{ background:#c3cad6;}

/* ---------- 模态框 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20,28,45,.45); display: none;
  align-items: flex-start; justify-content: center; z-index: 100; overflow:auto; padding: 40px 16px; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 480px; max-width: 100%; padding: 26px 28px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal h3 { margin-bottom: 4px; display:flex; align-items:center; gap:8px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- 树 ---------- */
.tree { user-select: none; }
.tree .node { margin: 2px 0; }
.tree .row { display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 7px; cursor: default; }
.tree .row:hover { background: #eef2fa; }
.tree .row.group-row { cursor: pointer; font-weight: 600; }
.tree .row.group-row[draggable="true"] { cursor: grab; }
.tree .row.group-row[draggable="true"]:active { cursor: grabbing; }
.tree .row.drop-hover {
  background: #d8e5ff !important;
  box-shadow: inset 0 0 0 2px var(--primary), 0 2px 8px rgba(36,86,196,.18);
  border-radius: 7px;
}
.tree .row.drop-hover .label { color: var(--primary-dark); }
.tree .row .dev { cursor: grab; font-weight: 400; color: var(--text); }
.tree .row.dev-row { cursor: grab; }
.tree .row.dev-row:active { cursor: grabbing; }
.tree .row.dragging { opacity: .4; }
.tree .row.virtual-row { color: #5b6b86; }
.tree .children { margin-left: 22px; border-left: 1px dashed var(--border); padding-left: 8px; }
.tree .icon { width: 18px; text-align: center; }
.tree .badge { background:#eceff4; color:var(--muted); font-size:11px; padding:1px 7px; border-radius:8px; }
.tree .ops { margin-left: auto; display:none; gap:4px; }
.tree .row:hover .ops { display:flex; }
.icon-btn { border:none; background:#eef1f7; border-radius:5px; cursor:pointer; padding:3px 7px; font-size:12px; color:#42506b;}
.icon-btn.red { color: var(--danger); background:#fdeaea; }

/* ---------- 固件卡片 ---------- */
.fw-grid { display:grid; grid-template-columns: 1fr 1fr; gap:16px; }
@media (max-width: 900px){ .fw-grid{ grid-template-columns:1fr; } }
.fw-card { background:#fff; border:1px solid var(--border); border-radius:10px; padding:16px 18px; box-shadow:0 1px 4px rgba(30,50,90,.06);}
.fw-card .head { display:flex; align-items:center; gap:8px; margin-bottom:6px;}
.fw-card .title { font-size:16px; font-weight:700; color: var(--primary-dark); }
.fw-card .meta { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; display:flex; gap:14px; flex-wrap:wrap;}
.fw-card .fileline { font-size:12.5px; color:var(--muted); margin-bottom:8px;}
.linkbox { display:flex; gap:6px; align-items:center; margin-bottom:6px; }
.linkbox input { font-family:Consolas,monospace; font-size:12px; color:#51607a; background:#f7f9fc; padding:6px 8px;}

/* ---------- 提示 ---------- */
#toast { position: fixed; top: 66px; right: 20px; z-index: 200; display:flex; flex-direction:column; gap:8px;}
.toast-item { padding: 11px 18px; border-radius: 8px; color:#fff; font-size:13.5px; box-shadow:0 4px 14px rgba(0,0,0,.2); animation: fadein .2s;}
.toast-item.ok { background: var(--success); }
.toast-item.err { background: var(--danger); }
@keyframes fadein { from { opacity:0; transform: translateY(-6px);} to{opacity:1;} }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display:flex; align-items:center; justify-content:center;
  background: linear-gradient(135deg, #24467e 0%, #2456c4 55%, #3f7ae0 100%); }
.login-box { background:#fff; border-radius:14px; padding:36px 38px; width:400px; box-shadow:0 18px 50px rgba(0,0,0,.3);}
.login-box h2 { text-align:center; margin-bottom:4px; color:var(--primary-dark); }
.login-box .sub { text-align:center; color:var(--muted); margin-bottom:18px; font-size:13px;}
.login-box .err { color:var(--danger); font-size:13px; min-height:18px; margin:8px 0 2px; text-align:center;}

.toolbar { display:flex; gap:10px; align-items:center; margin-bottom:14px; flex-wrap:wrap;}
.toolbar input[type=text] { width: 240px; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.checkbox-line { display:flex; align-items:center; gap:8px; margin:10px 0; font-size:13.5px;}
.auto-bind { display:inline-flex; align-items:center; gap:5px; font-size:12px; color:var(--muted);
  margin-left:8px; font-weight:400; cursor:pointer; }
.auto-bind input { margin:0; width:auto; }
.auto-bind:hover { color: var(--primary); }

/* ---------- 搜索候选下拉 ---------- */
.suggest-wrap { position: relative; display: inline-block; }
.suggest-box {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; min-width: 230px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(20, 40, 80, .16);
  max-height: 300px; overflow: auto; display: none; z-index: 80;
}
.suggest-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; cursor: pointer; font-size: 13.5px; white-space: nowrap;
}
.suggest-item:hover, .suggest-item.active { background: var(--primary-light); }
.suggest-item .meta { color: var(--muted); font-size: 12px; }
hr.sep { border:none; border-top:1px solid var(--border); margin:14px 0; }
