:root {
  --blue: #2f5bea;
  --blue-600: #2449cf;
  --blue-700: #1d3cb0;
  --blue-soft: #eaf0ff;
  --ink: #141a2e;
  --ink-2: #44506b;
  --muted: #8a95ad;
  --line: #e7eaf2;
  --bg: #eef0f5;
  --card: #ffffff;
  --green: #10b981;
  --green-soft: #e7f8f1;
  --red: #ef4444;
  --red-soft: #fdecec;
  --amber: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(24, 34, 64, 0.08);
  --shadow-sm: 0 2px 8px rgba(24, 34, 64, 0.06);
  --sidebar-w: 236px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ============ 登录页 ============ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 1px 1px, rgba(90, 110, 160, 0.16) 1.3px, transparent 0);
  background-size: 22px 22px;
  background-color: var(--bg);
  position: relative;
}
.lang-toggle {
  position: absolute;
  top: 22px; right: 26px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-2);
  font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  animation: rise .5s cubic-bezier(.2,.7,.3,1) both;
}
.brand-mark { margin: 0 auto 10px; width: 132px; height: 92px; }
.brand-name {
  letter-spacing: .5em;
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
  margin: 0 0 4px;
  padding-left: .5em;
}
.brand-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 30px; letter-spacing: .04em; }

.field-group {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
}
.field-group .field + .field { border-top: 1px solid var(--line); }
.field { position: relative; }
.field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 18px 20px 18px 48px;
  font-size: 15px;
  color: var(--ink);
}
.field input::placeholder { color: var(--muted); }
.field .ic {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  color: var(--muted); width: 18px; height: 18px;
}
.btn-primary {
  margin-top: 20px;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 15px;
  font-size: 15px; font-weight: 700; letter-spacing: .08em;
  color: #fff;
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-600) 100%);
  box-shadow: 0 8px 20px rgba(47, 91, 234, .32);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(47,91,234,.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.auth-err {
  margin-top: 14px; min-height: 18px;
  color: var(--red); font-size: 13px;
}
.auth-hint { margin-top: 26px; color: var(--muted); font-size: 12px; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ============ 应用骨架 ============ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; }
.side-brand .logo { width: 34px; height: 34px; }
.side-brand b { font-size: 16px; letter-spacing: .12em; }
.side-brand span { font-size: 11px; color: var(--muted); display: block; letter-spacing: .18em; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 14px; font-weight: 600;
  transition: background .12s, color .12s;
}
.nav a .ic { width: 18px; height: 18px; color: var(--muted); }
.nav a:hover { background: #f4f6fb; color: var(--ink); }
.nav a.active { background: var(--blue-soft); color: var(--blue); }
.nav a.active .ic { color: var(--blue); }
.nav .badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--blue); color: #fff; border-radius: 999px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
}
.side-foot { margin-top: auto; padding: 12px 10px 0; }
.lang-btn { display: flex; align-items: center; gap: 9px; padding: 9px 12px; margin-bottom: 8px;
  border-radius: var(--radius-sm); color: var(--ink-2); font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--line); cursor: pointer; transition: all .12s; }
.lang-btn:hover { background: #f4f6fb; color: var(--blue); border-color: #cfd6e6; }
.lang-btn .ic { color: var(--muted); }
/* 设备筛选器 */
.dev-filter { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line);
  background: #fff; border-radius: var(--radius-sm); padding: 0 10px 0 12px; height: 38px; }
.dev-filter svg { width: 15px; height: 15px; color: var(--muted); }
.dev-filter select { border: 0; outline: 0; background: transparent; font-size: 13.5px; font-weight: 600;
  color: var(--ink-2); padding: 8px 4px; cursor: pointer; }
.dev-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: #eef1f8; color: var(--muted); white-space: nowrap; }
.dev-badge svg { width: 11px; height: 11px; }
.side-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.side-user .av {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #7aa0ff);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.side-user .logout { margin-left: auto; color: var(--muted); }
.side-user .logout:hover { color: var(--red); }

.main { padding: 26px 32px 48px; width: 100%; min-width: 0; }
.topbar { display: flex; align-items: center; margin-bottom: 22px; gap: 14px; }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: .01em; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.topbar .actions { margin-left: auto; display: flex; gap: 10px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: var(--radius-sm); padding: 9px 14px; font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; transition: all .12s;
}
.btn:hover { border-color: #cfd6e6; color: var(--ink); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-600); }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn .ic { width: 16px; height: 16px; }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.stat .label .ic { width: 16px; height: 16px; }
.stat .val { font-size: 26px; font-weight: 800; margin-top: 10px; letter-spacing: -.01em; }
.stat .val.pos { color: var(--green); }
.stat .val.neg { color: var(--red); }
.stat .foot { margin-top: 6px; font-size: 12px; color: var(--muted); }

.cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  overflow: hidden; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 6px 0; overflow-x: auto; }
.card-body.pad { padding: 18px; }

/* 列表项（短信/通知） */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 13px; padding: 13px 18px; border-bottom: 1px solid var(--line); transition: background .1s; }
.item:last-child { border-bottom: 0; }
.item:hover { background: #fafbff; }
.item .ava {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: var(--blue);
}
.item .body { flex: 1; min-width: 0; }
.item .row1 { display: flex; align-items: baseline; gap: 8px; }
.item .row1 b { font-size: 13.5px; }
.item .row1 .time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.item .text { color: var(--ink-2); font-size: 13px; margin-top: 3px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .del { color: var(--muted); align-self: center; opacity: 0; transition: opacity .1s; padding: 4px; }
.item:hover .del { opacity: 1; }
.item .del:hover { color: var(--red); }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #fafbff; }
.amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.in { color: var(--green); }
.amt.out { color: var(--red); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; }
.pill.in { background: var(--green-soft); color: var(--green); }
.pill.out { background: var(--red-soft); color: var(--red); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: #f1f4fb; color: var(--ink-2); white-space: nowrap; }
.tag .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }

/* 银行卡片 */
.bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.bankcard {
  border-radius: var(--radius); padding: 18px; color: #fff; position: relative;
  box-shadow: var(--shadow); min-height: 150px; display: flex; flex-direction: column;
  background: linear-gradient(135deg, var(--blue), var(--blue-700));
  overflow: hidden;
}
.bankcard::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px;
  border-radius: 50%; background: rgba(255,255,255,.12); }
.bankcard .bk-top { display: flex; align-items: center; gap: 10px; }
.bankcard .bk-logo { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.22);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.bankcard .bk-name { font-weight: 700; font-size: 15px; }
.bankcard .bk-no { font-size: 13px; opacity: .85; letter-spacing: .08em; margin-top: 2px; }
.bankcard .bk-stats { margin-top: auto; display: flex; gap: 18px; position: relative; z-index: 1; }
.bankcard .bk-stats .s small { opacity: .8; font-size: 11px; display: block; }
.bankcard .bk-stats .s b { font-size: 16px; font-variant-numeric: tabular-nums; }
.bankcard .bk-edit { position: absolute; top: 14px; right: 14px; color: rgba(255,255,255,.8); z-index: 2; }
.bankcard .bk-edit:hover { color: #fff; }
.bankcard.add {
  background: #fff; color: var(--muted); border: 2px dashed var(--line);
  align-items: center; justify-content: center; box-shadow: none; cursor: pointer; gap: 8px;
}
.bankcard.add:hover { border-color: var(--blue); color: var(--blue); }

/* 空状态 */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 13.5px; }
.empty .ic { width: 34px; height: 34px; margin: 0 auto 10px; opacity: .5; }

/* 接入卡片 */
.ingest-box { background: #0f1428; color: #d7dcea; border-radius: var(--radius); padding: 16px 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.7;
  overflow-x: auto; }
.ingest-box .k { color: #7aa0ff; }
.ingest-box .s { color: #8ee6b4; }
.device-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.device-row:last-child { border-bottom: 0; }
.device-row code { background: #f1f4fb; padding: 3px 8px; border-radius: 6px; font-size: 12px; color: var(--ink-2); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(16,22,44,.42); display: none;
  place-items: center; z-index: 50; padding: 20px; backdrop-filter: blur(2px); }
.modal-mask.show { display: grid; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 440px;
  box-shadow: 0 24px 60px rgba(16,22,44,.3); animation: rise .25s ease both; }
.modal h3 { margin: 0; padding: 18px 20px; border-bottom: 1px solid var(--line); font-size: 16px; }
.modal .mbody { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal .mfoot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
label.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.fld input, label.fld select {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; color: var(--ink);
  outline: none; transition: border .12s;
}
label.fld input:focus, label.fld select:focus { border-color: var(--blue); }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-col { display: flex; flex-direction: column; gap: 14px; max-width: 440px; }
.form-col .btn { align-self: flex-start; margin-top: 4px; }
.seg { display: inline-flex; background: #f1f4fb; border-radius: var(--radius-sm); padding: 3px; }
.seg button { border: 0; background: transparent; padding: 8px 16px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.seg button.on-in { background: var(--green); color: #fff; }
.seg button.on-out { background: var(--red); color: #fff; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 13.5px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s; z-index: 80; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .main { padding: 18px 16px 40px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex !important; }
}
.menu-btn { display: none; }
