:root {
  --pri: #1a5fd0;
  --pri-dark: #14479c;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e3e8f0;
  --text: #1f2733;
  --sub: #6b7688;
  --nav: #16233a;
  --nav-hover: #1f2f4d;
  --ok: #12a150;
  --warn: #e08b00;
  --danger: #d9363e;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}
a { color: var(--pri); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* 布局 */
.layout { display: flex; min-height: 100dvh; }
.sidebar {
  width: 216px; flex: 0 0 216px; background: var(--nav); color: #c9d3e4;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
}
.brand { padding: 18px 18px 14px; font-size: 15px; font-weight: 600; color: #fff; letter-spacing: .5px; }
.brand small { display: block; font-size: 11px; color: #7f8da6; font-weight: 400; margin-top: 4px; letter-spacing: 0; }
.nav { flex: 1; overflow: auto; padding: 6px 0 20px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px; color: #c9d3e4; font-size: 14px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--nav-hover); color: #fff; }
.nav a.on { background: var(--nav-hover); color: #fff; border-left-color: var(--pri); }
.nav .ico { width: 16px; text-align: center; opacity: .8; }
.nav-group { padding: 14px 18px 6px; font-size: 11px; color: #6c7a92; letter-spacing: 1px; }
.sidebar .foot { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; color: #7f8da6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .who { font-size: 13px; color: var(--sub); display: flex; gap: 12px; align-items: center; }
.content { padding: 18px 20px 40px; }

/* 组件 */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 14px; }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; }
.muted { color: var(--sub); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.right { margin-left: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1100px) { .grid4 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: 1fr 1fr; } }

button, .btn {
  border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; white-space: nowrap; transition: .15s;
}
button:hover, .btn:hover { border-color: #c3cdde; background: #f8faff; }
.btn-pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn-pri:hover { background: var(--pri-dark); border-color: var(--pri-dark); }
.btn-danger { color: var(--danger); border-color: #f2c7c9; }
.btn-danger:hover { background: #fff4f4; }
.btn-sm { padding: 4px 9px; font-size: 13px; border-radius: 6px; }
.btn-link { border: none; background: none; color: var(--pri); padding: 2px 6px; }
.btn-link:hover { background: #eef4ff; }
button:disabled { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], input[type=datetime-local], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; background: #fff; color: var(--text);
  outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(26,95,208,.1); }
textarea { resize: vertical; min-height: 70px; line-height: 1.6; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--sub); margin-bottom: 4px; }
label.inline { display: flex; align-items: center; gap: 6px; font-size: 13px; }
label.inline input { width: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--sub); font-weight: 500; background: #fafbfd; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: #fafcff; }
.table-wrap { overflow: auto; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; background: #eef2f8; color: var(--sub); }
.tag.ok { background: #e7f7ee; color: var(--ok); }
.tag.warn { background: #fff5e2; color: var(--warn); }
.tag.danger { background: #fdeceb; color: var(--danger); }
.tag.pri { background: #e9f0ff; color: var(--pri); }

.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 24px; font-weight: 600; line-height: 1.3; }
.stat span { font-size: 12px; color: var(--sub); }

/* 树 */
.tree { font-size: 13px; user-select: none; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; }
.tree > ul { padding-left: 0; }
.tree .node {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; cursor: pointer;
}
.tree .node:hover { background: #f2f6fd; }
.tree .node.on { background: #e9f0ff; color: var(--pri); font-weight: 500; }
.tree .node .cnt { color: var(--sub); font-size: 11px; margin-left: auto; }
.tree .node .acts { display: none; gap: 2px; margin-left: 4px; }
.tree .node:hover .acts { display: flex; }
.tree .caret { width: 14px; color: var(--sub); font-size: 10px; }

/* 弹窗 */
.mask {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; align-items: flex-start;
  justify-content: center; z-index: 100; padding: 40px 16px; overflow: auto;
}
.dialog { background: #fff; border-radius: 12px; width: 640px; max-width: 100%; box-shadow: 0 24px 60px rgba(0,0,0,.2); }
.dialog.wide { width: 900px; }
.dialog.narrow { width: 440px; }
.dialog-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dialog-h b { font-size: 15px; }
.dialog-b { padding: 16px 18px; max-height: 68vh; overflow: auto; }
.dialog-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.close { border: none; background: none; font-size: 18px; color: var(--sub); cursor: pointer; line-height: 1; }

/* toast */
#toast { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2733; color: #fff; padding: 9px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: tin .18s ease-out;
}
.toast.err { background: #c0392b; }
.toast.ok { background: #127a44; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

/* 登录 */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#16305c,#0f1c30); }
.login-box { width: 360px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-box h2 { margin: 0 0 4px; font-size: 18px; }
.login-box p { margin: 0 0 20px; color: var(--sub); font-size: 12px; }

/* 杂项 */
.empty { text-align: center; color: var(--sub); padding: 28px 0; font-size: 13px; }
.split { display: grid; grid-template-columns: 260px 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.picklist { border: 1px solid var(--line); border-radius: 8px; max-height: 300px; overflow: auto; padding: 6px; }
.picklist label { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 6px; font-size: 13px; }
.picklist label:hover { background: #f5f8fd; }
.picklist label input { width: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #eef2f8; border-radius: 20px; padding: 3px 10px; font-size: 12px; margin: 0 6px 6px 0; }
.chip b { font-weight: 600; }
.hint { font-size: 12px; color: var(--sub); line-height: 1.7; }
.hint code { background: #f2f5fa; padding: 1px 5px; border-radius: 4px; font-size: 12px; color: #b4441f; }
.dragging { background: #fffbe6; }
.progressbar { height: 6px; background: #eef2f8; border-radius: 6px; overflow: hidden; }
.progressbar i { display: block; height: 100%; background: var(--pri); }
