* { box-sizing: border-box; margin: 0; }
body { font-family: "PingFang SC", "Microsoft YaHei", sans-serif; background: #f1f5f9; color: #1f2937; font-size: 14px; }

.topbar { display: flex; align-items: center; gap: 28px; background: #fff; border-bottom: 1px solid #e2e8f0; padding: 0 28px; height: 56px; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: #1e3a8a; font-size: 15px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 14px; border-radius: 8px; color: #475569; text-decoration: none; }
.topbar nav a.active, .topbar nav a:hover { background: #eff6ff; color: #1d4ed8; }
.userbox { display: flex; align-items: center; gap: 10px; }
.rolebadge { background: #ede9fe; color: #6d28d9; padding: 2px 10px; border-radius: 10px; font-size: 12px; }

main { max-width: 1120px; margin: 0 auto; padding: 26px 24px 60px; }
h2.page-title { font-size: 19px; color: #0f172a; margin-bottom: 6px; }
.page-desc { color: #64748b; margin-bottom: 22px; font-size: 13px; }

button { cursor: pointer; border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; padding: 7px 14px; font-size: 13px; color: #334155; }
button:hover { border-color: #94a3b8; }
button.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
button.primary:hover { background: #1d4ed8; }
button.danger { background: #fff; color: #dc2626; border-color: #fca5a5; }
button.ghost { border: none; color: #64748b; }
button.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea { border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit; width: 100%; background: #fff; }
textarea { resize: vertical; }
label.fl { display: block; font-size: 12.5px; color: #475569; margin: 10px 0 4px; font-weight: 600; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 36px 40px; width: 400px; box-shadow: 0 10px 40px rgba(15,23,42,.08); }
.login-card h1 { font-size: 19px; color: #1e3a8a; margin-bottom: 4px; }
.login-card p { color: #64748b; font-size: 12.5px; margin-bottom: 18px; }
.demo-user { display: flex; justify-content: space-between; align-items: center; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; }
.demo-user:hover { border-color: #93c5fd; background: #f8fafc; }
.demo-user .n { font-weight: 600; }
.demo-user .r { font-size: 12px; color: #6d28d9; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px 18px; }
.card .name { font-size: 12.5px; color: #64748b; margin-bottom: 6px; }
.card .value { font-size: 24px; font-weight: 700; color: #1e293b; }
.card .value small { font-size: 12px; font-weight: 400; color: #94a3b8; margin-left: 2px; }
.card .sub { font-size: 11.5px; color: #94a3b8; margin-top: 2px; }

.panel { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px 22px; margin-bottom: 18px; }
.panel h3 { font-size: 15px; color: #1e293b; margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; background: #f8fafc; color: #475569; font-weight: 600; padding: 9px 10px; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }

.badge { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 10px; font-weight: 600; }
.b-green { background: #dcfce7; color: #047857; } .b-gray { background: #f1f5f9; color: #64748b; }
.b-blue { background: #dbeafe; color: #1d4ed8; } .b-purple { background: #ede9fe; color: #6d28d9; }
.b-red { background: #fee2e2; color: #b91c1c; } .b-amber { background: #fef3c7; color: #b45309; }
.b-teal { background: #ccfbf1; color: #0f766e; }

.alert-box { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.ok-box { background: #f0fdf4; border: 1px solid #bbf7d0; color: #047857; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.gate-box { background: #fef2f2; border: 1px solid #fca5a5; border-radius: 10px; padding: 14px 16px; margin: 12px 0; font-size: 13px; color: #991b1b; }
.gate-box b { color: #b91c1c; }

.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; padding: 24px 26px; width: 520px; max-height: 86vh; overflow-y: auto; }
.modal h3 { margin-bottom: 4px; font-size: 16px; }
.modal .meta { color: #64748b; font-size: 12.5px; margin-bottom: 12px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

pre.json { background: #f8fafc; border: 1px solid #e2e8f0; border-left: 3px solid #2563eb; border-radius: 8px; padding: 12px 14px; font-size: 12px; font-family: Consolas, monospace; overflow-x: auto; max-height: 340px; line-height: 1.55; }
.muted { color: #94a3b8; font-size: 12px; }
.sla { font-size: 12px; padding: 1px 8px; border-radius: 8px; }
.sla.warn { background: #fef3c7; color: #b45309; } .sla.danger { background: #fee2e2; color: #b91c1c; } .sla.ok { background: #dcfce7; color: #047857; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { border-radius: 999px; }
.tabs button.on { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chip { display: inline-block; background: #eff6ff; color: #1d4ed8; border-radius: 6px; padding: 1px 7px; font-size: 11px; margin: 0 4px 4px 0; }

.qa-box { background: #f8fafc; border: 1px solid #e2e8f0; border-left: 3px solid #6d28d9; border-radius: 10px; padding: 14px 16px; }
.qa-answer { font-size: 13px; line-height: 1.7; color: #334155; }
.qa-cites { margin-top: 10px; padding-top: 8px; border-top: 1px dashed #e2e8f0; font-size: 12px; color: #64748b; }

/* 四期面板：MQTT 网关 / 安全通道 / 向量索引 */
.cards.three { grid-template-columns: repeat(3, 1fr); }
.card .k { font-size: 12.5px; color: #64748b; margin-bottom: 6px; }
.card .v { font-size: 22px; font-weight: 700; color: #1e293b; }
.card .v.ok { color: #047857; }
.card .v.bad { color: #b91c1c; }
.card .sub { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.alert { border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: 13px; }
.alert.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #047857; }
.alert.bad { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }

/* ============ 左侧边栏布局 + 登录页双模式 + 页脚备案 ============ */
html, body { height: 100%; }
#app { display: flex; min-height: 100vh; }
.sidebar { width: 216px; background: #0f172a; color: #cbd5e1; display: none; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar.show { display: flex; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid #1e293b; }
.side-logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg,#1e3a8a,#3b82f6); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.side-brand-txt b { display: block; color: #fff; font-size: 14px; }
.side-brand-txt span { display: block; font-size: 11px; color: #64748b; margin-top: 2px; }
.side-user { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #1e293b; }
.side-user .ghost { margin-left: auto; padding: 3px 10px; font-size: 11px; background: transparent; color: #94a3b8; border-color: #334155; }
.side-user .ghost:hover { color: #f87171; border-color: #7f1d1d; }
.side-avatar { width: 32px; height: 32px; border-radius: 50%; background: #1e3a8a; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.side-userinfo { min-width: 0; }
.side-userinfo b { display: block; color: #f1f5f9; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100px; }
.side-nav { flex: 1; padding: 6px 0 14px; }
.side-group { margin-top: 10px; }
.side-group-title { font-size: 11px; color: #475569; padding: 6px 18px 4px; letter-spacing: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 18px; color: #94a3b8; text-decoration: none; font-size: 13px; border-left: 3px solid transparent; }
.side-nav a i { font-style: normal; width: 18px; text-align: center; opacity: .8; font-size: 13px; }
.side-nav a:hover { background: #1e293b; color: #e2e8f0; }
.side-nav a.active { background: #1e293b; color: #fff; border-left-color: #3b82f6; }
.side-nav a.active i { opacity: 1; }
.side-icp { padding: 12px 16px 16px; border-top: 1px solid #1e293b; }
.side-icp a { color: #475569; font-size: 11px; text-decoration: none; }
.side-icp a:hover { color: #94a3b8; }
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid #e2e8f0; padding: 0 20px; height: 52px; position: sticky; top: 0; z-index: 10; }
.topbar .brand { font-weight: 700; color: #1e3a8a; font-size: 14px; }
.burger { display: none; background: none; border: 0; font-size: 20px; color: #475569; padding: 4px 8px; cursor: pointer; }
#app.main { max-width: none; }
main { flex: 1; }
.site-footer { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 18px; color: #94a3b8; font-size: 12px; border-top: 1px solid #e2e8f0; background: #f8fafc; }
.site-footer a { color: #94a3b8; text-decoration: none; }
.site-footer a:hover { color: #475569; }
@media (min-width: 861px) {
  .sidebar { display: flex !important; }
  .burger { display: none; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 60; left: -230px; transition: left .2s; height: 100vh; display: flex; }
  .sidebar.show { left: 0; display: flex; }
  .burger { display: inline-block; }
}
/* ---- 登录页双模式 ---- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 40px); padding: 20px; background: linear-gradient(160deg,#0f172a 0%,#1e3a8a 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 34px 36px 26px; width: 400px; max-width: 94vw; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h1 { font-size: 19px; color: #0f172a; margin-bottom: 4px; }
.login-card .login-sub { color: #94a3b8; font-size: 12px; margin-bottom: 20px; }
.login-tabs { display: flex; border-bottom: 1px solid #e2e8f0; margin-bottom: 20px; }
.login-tab { flex: 1; text-align: center; padding: 10px 0 12px; color: #64748b; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; user-select: none; }
.login-tab.on { color: #1e3a8a; font-weight: 700; border-bottom-color: #1e3a8a; }
.login-card input { width: 100%; box-sizing: border-box; border: 1px solid #e2e8f0; border-radius: 10px; padding: 11px 13px; font-size: 14px; margin-bottom: 12px; }
.login-card input:focus { outline: none; border-color: #1e3a8a; }
.login-card .primary { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.login-err { color: #b91c1c; font-size: 12px; min-height: 16px; margin: -6px 0 8px; }
.login-hint { text-align: center; color: #94a3b8; font-size: 11px; margin-top: 14px; }
.qr-box { text-align: center; padding: 6px 0 2px; }
.qr-img { width: 210px; height: 210px; border: 1px solid #e2e8f0; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; overflow: hidden; background: #fff; }
.qr-img img { width: 100%; height: 100%; object-fit: contain; }
.qr-ticket { font-size: 30px; letter-spacing: 8px; font-weight: 800; color: #1e3a8a; font-family: Consolas, monospace; }
.qr-status { font-size: 13px; color: #64748b; margin-top: 8px; }
.qr-status.ok { color: #059669; font-weight: 600; }
.qr-status.expired { color: #b91c1c; }
.qr-refresh { margin-top: 10px; }
.qr-steps { text-align: left; background: #f8fafc; border-radius: 10px; padding: 12px 14px; font-size: 12px; color: #64748b; line-height: 2; margin-top: 14px; }
.qr-steps b { color: #334155; }
.demo-users { max-height: 130px; overflow-y: auto; }