:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --border: #e5e6e8;
  --text: #1f2329;
  --muted: #8f959e;
  --accent: #4f7cff;
  --accent-hover: #3f6bea;
  --sidebar: #f7f7f8;
  --danger: #e5484d;
  --success: #18a058;
  --warning: #d97706;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
button {
  border: 1px solid #dcdfe6;
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
button:hover { background: #f2f3f5; border-color: #c9cdd3; }
button:disabled { color: #b0b4ba; background: #f7f8fa; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger); border-color: #f0c8c9; }
button.danger:hover { background: #fdecec; }
button.sm { padding: 5px 10px; font-size: 12px; }
input, select, textarea {
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; width: 100%; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 26px 0 !important; }

/* 登录 */
.login-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(245, 246, 247, .97);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 390px; max-width: calc(100vw - 32px);
  background: #fff; border: 1px solid var(--border);
  border-radius: 14px; padding: 32px;
  box-shadow: 0 18px 50px rgba(31, 35, 41, .08);
}
.login-logo {
  display: block;
  width: 150px;
  height: 52px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 16px;
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 12px; line-height: 1.6; }
.login-card .field { margin-bottom: 12px; }
.login-card .field input { width: 100%; }
.error { color: var(--danger); font-size: 12px; margin-top: 10px; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: 220px;
  background: var(--sidebar); border-right: 1px solid var(--border);
  padding: 20px 14px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 20px; }
.brand-mark {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 8px; background: #fff;
  object-fit: contain;
}
.brand h1 { font-size: 16px; margin: 0; }
.brand small { color: var(--muted); font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 7px;
  color: #5c626b; cursor: pointer; font-size: 13px;
}
.nav a:hover { background: #eef0f3; }
.nav a.active { background: #eaf0ff; color: #2f5bff; font-weight: 600; }
.nav .ico { width: 18px; text-align: center; font-size: 14px; }
.main { margin-left: 220px; width: calc(100% - 220px); padding: 22px 28px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 21px; }
.topbar .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }

/* 卡片 / 面板 */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat {
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px;
}
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 25px; font-weight: 700; margin-top: 6px; white-space: nowrap; }
.stat .unit { font-size: 12px; color: var(--muted); font-weight: 400;
              margin-left: 5px; white-space: nowrap; }
.panel {
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px; margin-bottom: 16px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 12px;
}
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-head .actions { display: flex; gap: 8px; align-items: center; }

/* 表格 */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 9px 12px; background: #fafbfc;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td {
  padding: 10px 12px; border-bottom: 1px solid #f0f1f3;
  white-space: nowrap; vertical-align: middle;
}
tbody tr:hover td { background: #fafbff; }
td.ops { white-space: nowrap; }
td.ops button + button { margin-left: 6px; }

/* 徽章 */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; line-height: 18px; background: #f2f3f5; color: var(--muted);
}
.badge.active { background: #e8f7ee; color: var(--success); }
.badge.danger { background: #fdecec; color: var(--danger); }
.badge.warning { background: #fdf3e5; color: var(--warning); }
.badge.muted { background: #f2f3f5; color: var(--muted); }

/* 表单 */
.form-row {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 14px;
}
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; align-items: end; margin-bottom: 14px;
}
.field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; }
.field.grow { flex: 1 1 240px; }
.checkline { display: flex; gap: 16px; align-items: center; padding-bottom: 8px; }
.checkline label { display: flex; gap: 6px; align-items: center; color: #5c626b; }
.notice-form .field { margin-bottom: 12px; }
.code-result {
  background: #f7f8fa; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; white-space: pre-wrap; font-family: Consolas, monospace;
  font-size: 12px; max-height: 220px; overflow: auto; margin: 0;
}

/* 分页 / 提示 */
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); }
.toast {
  position: fixed; right: 24px; top: 20px; z-index: 80;
  background: #1f2329; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 12px; opacity: 0; transform: translateY(-6px);
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #b42318; }

@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 14px 8px; }
  .brand { padding: 2px 8px 16px; justify-content: center; }
  .brand div:last-child, .nav a span:last-child { display: none; }
  .nav a { justify-content: center; padding: 10px 0; }
  .main { margin-left: 64px; width: calc(100% - 64px); padding: 16px; }
}
