:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e4e8ee;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.center { text-align: center; }
.error { color: var(--danger); margin-top: 8px; font-size: 13px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 28px;
  text-align: center;
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .muted { margin-bottom: 20px; }
.login-card input { margin-bottom: 12px; }

/* ---------- 卡片 / 布局 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-head h2 { font-size: 17px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
#tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  border: none;
  background: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}
.tab:hover { background: #eef2f7; color: var(--text); }
.tab.active { background: #e8effd; color: var(--primary); font-weight: 600; }

main { max-width: 1080px; margin: 24px auto; padding: 0 20px 40px; }

/* ---------- 表单 ---------- */
input, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label input, label select { margin-top: 4px; color: var(--text); }

.inline-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.inline-form input { flex: 1; min-width: 160px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 20px;
  max-width: 720px;
}
.form-actions { grid-column: 1 / -1; margin-top: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #f3f5f8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #f0c4c4; }
.btn.danger:hover { background: #fdf1f1; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 10px;
  border-bottom: 1px solid #f0f2f6;
  vertical-align: top;
}
.table tbody tr:hover { background: #f9fafc; }
.table td.detail { white-space: pre-wrap; max-width: 420px; }

/* ---------- 开关 ---------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; margin: 0; }
.switch input { display: none; }
.switch span {
  position: absolute; inset: 0;
  background: #d1d5db;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.15s;
}
.switch span::after {
  content: "";
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ---------- 标签 ---------- */
.chip {
  display: inline-block;
  background: #eef2f7;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  margin: 2px 4px 2px 0;
}
.badge-and { color: var(--primary); font-weight: 600; }
.badge-or { color: #d97706; font-weight: 600; }

/* ---------- 模态框 ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; font-size: 16px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.cond-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: var(--text);
  margin: 0;
}
.cond-check input { width: auto; }

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

/* ---------- 提示 ---------- */
.info-box {
  margin-top: 20px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
}

#toast-root {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); color: #fff; margin-top: 0; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .table td.detail { max-width: 220px; }
}
