:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e8ef;
  --border-strong: #cfd7e3;
  --text: #1c2530;
  --text-2: #5b6b7c;
  --text-3: #8494a6;
  --brand: #2f6fed;
  --brand-soft: #eaf1ff;
  --green: #148a4b;
  --green-soft: #e6f5ec;
  --red: #c02b2b;
  --red-soft: #fdeaea;
  --amber: #a86800;
  --amber-soft: #fff4e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

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

/* ---------------------------------------------------------------- 鐧诲綍椤?*/

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 500px at 50% -10%, #e8f0ff 0%, var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px 26px 24px;
}

.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { margin: 0 0 20px; color: var(--text-2); font-size: 13px; }

/* ---------------------------------------------------------------- 甯冨眬 */

.shell { display: none; min-height: 100%; }
.shell.active { display: block; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .logo { font-weight: 600; font-size: 15px; }
.topbar .logo span { color: var(--text-3); font-weight: 400; margin-left: 8px; font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }

.layout { display: flex; min-height: calc(100vh - 56px); }

.sidebar {
  width: 196px;
  flex: 0 0 196px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item .ico { width: 16px; text-align: center; opacity: .9; }

.main { flex: 1; padding: 20px 24px 40px; min-width: 0; }

.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 18px; }
.page-head p { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------------------------------------------------------------- 鍗＄墖涓庣粺璁?*/

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card .label { color: var(--text-2); font-size: 12.5px; }
.card .value { font-size: 24px; font-weight: 600; margin-top: 4px; letter-spacing: .3px; }
.card .hint { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.card.warn .value { color: var(--amber); }
.card.bad .value { color: var(--red); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.panel > h3 { margin: 0 0 12px; font-size: 15px; }
.panel > h3 .muted { color: var(--text-3); font-weight: 400; font-size: 12.5px; margin-left: 8px; }

/* ---------------------------------------------------------------- 琛ㄥ崟 */

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: 12.5px; color: var(--text-2); }
.field .tip { font-size: 12px; color: var(--text-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 111, 237, .12); }
textarea { resize: vertical; min-height: 64px; }
input.inline, select.inline { width: auto; min-width: 130px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #2560d4; }
.btn.danger { color: var(--red); border-color: #f0c4c4; background: var(--red-soft); }
.btn.danger:hover { background: #fbdcdc; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }

/* ---------------------------------------------------------------- 琛ㄦ牸 */

.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  font-size: 12.5px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfcfe; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: 4px; }

.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.empty { padding: 36px 16px; text-align: center; color: var(--text-3); }

/* ---------------------------------------------------------------- 寰芥爣 */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.admin { background: #eef2ff; border-color: #d6e0ff; color: #3a55c4; }
.badge.agent { background: #eefaf6; border-color: #cef0e2; color: #127a58; }
.badge.user { background: #f4f6f8; border-color: #e3e8ef; color: #5b6b7c; }
.badge.ok { background: var(--green-soft); border-color: #cdeada; color: var(--green); }
.badge.off { background: var(--red-soft); border-color: #f4cccc; color: var(--red); }
.badge.warn { background: var(--amber-soft); border-color: #f5e0b8; color: var(--amber); }

/* ---------------------------------------------------------------- 寮圭獥 */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .38);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 60;
}
.modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 64px);
  overflow: auto;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(16, 24, 40, .25);
}
.modal header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.modal header .close { margin-left: auto; }
.modal .body { padding: 18px 20px; }
.modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 12px 12px;
}
.modal .notice {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: #1f4bb8;
  font-size: 13px;
  margin-bottom: 14px;
}
.modal .notice.bad { background: var(--red-soft); color: var(--red); }
.password-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 15px;
  letter-spacing: .5px;
}

/* ---------------------------------------------------------------- 鎻愮ず */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
}
.toast .item {
  min-width: 220px;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #1c2530;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  animation: slide-in .16s ease-out;
}
.toast .item.err { background: #8f1f1f; }
.toast .item.ok { background: #10673c; }

@keyframes slide-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tab {
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  border: 1px solid transparent;
}
.tab.active { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1080px) {
  .split { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

.badge.level-1 { background: #f4f6f8; border-color: #e3e8ef; color: #5b6b7c; }
.badge.level-2 { background: #eef2ff; border-color: #d6e0ff; color: #3a55c4; }
.badge.level-3 { background: #eefaf6; border-color: #cef0e2; color: #127a58; }
.badge.level-4 { background: #fdf3e7; border-color: #f2ddc0; color: #97601a; }
.badge.level-5 { background: #f6eefe; border-color: #e3d1f7; color: #6b2fa0; }
