:root {
  --primary: #165DFF;
  --primary-dark: #0E42D2;
  --primary-soft: #E8F0FF;
  --ok: #00B42A;
  --ok-soft: #E8FFEA;
  --warn: #FF7D00;
  --warn-soft: #FFF7E8;
  --bad: #F53F3F;
  --bad-soft: #FFECE8;
  --text: #1D2129;
  --text2: #4E5969;
  --text3: #86909C;
  --line: #E5E6EB;
  --line2: #F2F3F5;
  --bg: #F5F7FA;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 13px; display: flex; min-height: 100vh; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }

.sidebar { width: 204px; flex: none; background: #0E1729; color: #A9B4C8; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 9px; padding: 20px 18px 22px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(145deg, #2C6BFF, #5B8FFF); display: grid; place-items: center; color: #fff; flex: none; box-shadow: 0 6px 14px rgba(22, 93, 255, .4); }
.brand b { color: #fff; font-size: 14px; letter-spacing: .4px; display: block; }
.brand span { font-size: 10px; color: #65708A; letter-spacing: .6px; }
.navgroup { padding: 0 10px; margin-bottom: 4px; }
.navgroup .gt { font-size: 10px; color: #5B6680; letter-spacing: 1.4px; padding: 12px 10px 6px; font-weight: 600; }
.navitem { display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 10px; border-radius: 8px; font-size: 12.5px; color: #A9B4C8; transition: .15s; }
.navitem svg { opacity: .75; flex: none; }
.navitem:hover { background: rgba(255,255,255,.05); color: #E6ECF7; }
.navitem.active { background: linear-gradient(90deg, rgba(22,93,255,.9), rgba(22,93,255,.65)); color: #fff; box-shadow: 0 4px 14px -4px rgba(22,93,255,.7); }
.navitem.active svg { opacity: 1; }
.navitem .tag { margin-left: auto; background: rgba(255,255,255,.14); color: #C9D4E8; font-size: 9.5px; padding: 1px 6px; border-radius: 9px; }
.sidebar .foot { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.userbox { display: flex; align-items: center; gap: 9px; }
.userbox .ava { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(145deg, #2C6BFF, #5B8FFF); display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.userbox b { color: #E6ECF7; font-size: 12px; display: block; }
.userbox span { font-size: 10px; color: #65708A; }
.userbox .txt { min-width: 0; flex: 1; }
.logout-form button { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; color: #7C879D; }
.logout-form button:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; flex: none; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 26px; position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .crumb { font-size: 11.5px; color: var(--text3); }
.topbar .spacer { flex: 1; }
.topbar .topdate { font-size: 11.5px; color: var(--text3); }
.iconbtn2 { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--text3); }
.iconbtn2:hover { background: #F5F7FA; }
.content { padding: 22px 26px 34px; max-width: 1440px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; margin: 0 0 4px; }
.page-head p { margin: 0; font-size: 11.5px; color: var(--text3); }
.page-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; font-size: 12.5px; font-weight: 500; background: var(--primary); color: #fff; border: 1px solid var(--primary); transition: .15s; white-space: nowrap; }
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { background: #fff; color: var(--text2); border-color: var(--line); }
.btn.ghost:hover { color: var(--primary); border-color: #B8CDFF; background: #F8FAFF; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 11.5px; border-radius: 6px; }
.btn.danger { background: #fff; color: var(--bad); border-color: #FDC9C4; }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.cards4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid #EDEFF3; border-radius: 12px; padding: 16px 18px; position: relative; overflow: hidden; }
.stat .l { font-size: 11.5px; color: var(--text3); }
.stat .n { font-size: 27px; font-weight: 700; letter-spacing: .5px; margin: 7px 0 3px; line-height: 1.1; }
.stat .n small { font-size: 12px; font-weight: 400; color: var(--text3); margin-left: 3px; }
.stat .d { font-size: 10.5px; color: var(--text3); }
.stat .ic { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }

.grid2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; margin-bottom: 16px; }
.panel { background: #fff; border: 1px solid #EDEFF3; border-radius: 12px; overflow: hidden; }
.panel .ph { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line2); flex-wrap: wrap; }
.panel .ph h3 { font-size: 13.5px; margin: 0; font-weight: 600; }
.panel .ph .sub { font-size: 10.5px; color: var(--text3); margin-top: 2px; }
.panel .ph a { font-size: 11px; color: var(--primary); }
.panel .pb { padding: 16px 18px; }
.panel .pb.flush { padding: 0; }

.toolbar { display: flex; align-items: center; gap: 9px; padding: 12px 18px; border-bottom: 1px solid var(--line2); flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.field { display: flex; align-items: center; gap: 6px; height: 32px; border: 1px solid var(--line); border-radius: 7px; padding: 0 10px; background: #fff; font-size: 11.5px; color: var(--text2); }
.field input, .field select { border: 0; outline: 0; background: none; font-size: 11.5px; color: var(--text2); min-width: 100px; }
.field select { min-width: 120px; }
.field svg { color: #A9AEB8; flex: none; }

table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 10.5px; font-weight: 600; color: var(--text3); background: #FAFBFD; padding: 9px 14px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line2); font-size: 12px; vertical-align: middle; }
tbody tr:hover { background: #FAFCFF; }
tbody tr:last-child td { border-bottom: 0; }
tbody td:last-child { white-space: nowrap; }
.devcell { display: flex; align-items: center; gap: 10px; }
.devicon { width: 30px; height: 30px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.devcell b { font-size: 12px; font-weight: 600; display: block; line-height: 1.35; }
.devcell span { font-size: 10px; color: var(--text3); }
.muted { color: var(--text3); font-size: 11px; }
.num { font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 5px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.gray { background: #F2F3F5; color: var(--text3); }
.dotb { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.track { height: 8px; border-radius: 4px; background: #F2F4F8; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #165DFF, #5B8FFF); }
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 18px; font-size: 11px; color: var(--text3); }
.pager .spacer { flex: 1; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 11.5px; color: var(--text2); font-weight: 500; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #FAFBFC; padding: 0 11px; height: 36px; font-size: 12.5px; color: var(--text); outline: 0; transition: .15s; }
.textarea { height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(22,93,255,.08); }
.form-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 16px; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form .input, .inline-form .select { height: 30px; font-size: 11.5px; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text2); }

.empty { padding: 34px 18px; text-align: center; color: var(--text3); font-size: 12px; line-height: 1.8; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 12px; line-height: 1.7; margin-bottom: 14px; }
.alert.ok { background: var(--ok-soft); color: #087A22; border: 1px solid #B7F0C2; }
.alert.warn { background: var(--warn-soft); color: #9A5B00; border: 1px solid #FFD8A8; }
.alert.bad { background: var(--bad-soft); color: #A61B1B; border: 1px solid #FDC9C4; }
.alert.info { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #C9DAFF; }

.device-block { border-bottom: 1px solid var(--line2); }
.device-block:last-child { border-bottom: 0; }
.device-block > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 13px 18px; }
.device-block > summary::-webkit-details-marker { display: none; }
.device-block > summary:hover { background: #FAFCFF; }
.device-block .chev { color: #C0C4CC; transition: .2s; margin-left: auto; }
.device-block[open] .chev { transform: rotate(180deg); }
.device-items { padding: 0 18px 14px; }
.device-items table { border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.device-items thead th { background: #F8FAFD; }
.device-items tbody td { padding: 8px 10px; font-size: 11.5px; }
.item-actions { display: flex; gap: 10px; align-items: center; }
.link { color: var(--primary); font-size: 11.5px; }
.link.danger { color: var(--bad); }

.tpl-layout { display: grid; grid-template-columns: 280px 1fr; gap: 14px; align-items: start; }
.tpl-list { background: #fff; border: 1px solid #EDEFF3; border-radius: 12px; overflow: hidden; }
.tpl-list .hd { padding: 13px 15px; font-size: 11px; color: var(--text3); border-bottom: 1px solid var(--line2); display: flex; justify-content: space-between; }
.tpl { display: flex; align-items: center; gap: 9px; padding: 11px 15px; border-left: 3px solid transparent; }
.tpl:hover { background: #FAFCFF; }
.tpl.on { background: var(--primary-soft); border-left-color: var(--primary); }
.tpl .ti { width: 28px; height: 28px; border-radius: 7px; background: #F2F5FA; display: grid; place-items: center; color: var(--text3); flex: none; }
.tpl.on .ti { background: #fff; color: var(--primary); }
.tpl b { font-size: 12px; display: block; font-weight: 600; }
.tpl span { font-size: 10px; color: var(--text3); }
.tpl .cnt { margin-left: auto; font-size: 10.5px; color: var(--text3); }
.tpl.on .cnt { color: var(--primary); font-weight: 600; }

.login-body { min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center; background: radial-gradient(1000px 500px at 10% 0%, #DCE8FF, transparent 60%), radial-gradient(900px 500px at 100% 100%, #E4F7EE, transparent 55%), #F2F5FA; padding: 24px; }
.login-card { width: 380px; max-width: 100%; background: #fff; border-radius: 18px; padding: 30px 28px; box-shadow: 0 24px 60px -24px rgba(20,35,70,.35); }
.login-card .brandline { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-card .brandline .logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(145deg, #165DFF, #4C8BFF); display: grid; place-items: center; color: #fff; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card .sub { font-size: 11.5px; color: var(--text3); margin: 0; }
.login-card .form-row { margin-bottom: 14px; }
.login-card .btn { width: 100%; height: 42px; margin-top: 4px; }
.login-foot { text-align: center; font-size: 10.5px; color: var(--text3); margin-top: 18px; line-height: 1.8; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 40px; align-items: center; gap: 10px; font-size: 11px; color: var(--text2); }
.bar-row .v { text-align: right; font-weight: 600; color: var(--text); }
.donut { display: flex; align-items: center; gap: 18px; padding: 18px; }
.ring { width: 108px; height: 108px; border-radius: 50%; position: relative; flex: none; }
.ring::after { content: ""; position: absolute; inset: 14px; background: #fff; border-radius: 50%; }
.ring .c { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; text-align: center; }
.ring .c b { display: block; font-size: 19px; line-height: 1.1; }
.ring .c span { font-size: 9.5px; color: var(--text3); }
.legend { font-size: 11px; color: var(--text2); display: flex; flex-direction: column; gap: 9px; flex: 1; }
.legend div { display: flex; align-items: center; gap: 7px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.legend b { margin-left: auto; color: var(--text); font-weight: 600; }

@media (max-width: 1180px) {
  .cards4 { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .tpl-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .brand span, .brand b, .navitem span, .navitem .tag, .sidebar .foot .txt, .navgroup .gt { display: none; }
  .brand { justify-content: center; padding: 18px 0 14px; }
  .navitem { justify-content: center; padding: 0; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
