:root {
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-700: #3730a3;
  --brand-soft: #eef2ff;
  --brand-ring: rgba(79, 70, 229, 0.16);
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e7e9f0;
  --line-soft: #f1f3f9;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --green: #12b76a;
  --green-soft: #e8f8f0;
  --amber: #f79009;
  --red: #f04438;
  --red-soft: #fef3f2;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 2px 8px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 12px 32px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--brand);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: #d8dbe6;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: #c2c6d4;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------------------- 按钮 ---------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #fff;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.16s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:active {
  transform: translateY(0.5px);
}
.btn-primary {
  background: linear-gradient(180deg, #5b52ee 0%, var(--brand) 100%);
  color: #fff;
  border-color: rgba(0, 0, 0, 0.04);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.24);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-600) 100%);
}
.btn-outline {
  border-color: var(--line);
  background: #fff;
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
  border-color: #cfd4e2;
  background: #fbfbfe;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: var(--line-soft);
  color: var(--ink);
}
.btn-danger {
  color: var(--red);
  background: var(--red-soft);
  border-color: #fee4e2;
}
.btn-danger:hover {
  background: #fee4e2;
}
.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 8px;
}
.btn-lg {
  height: 46px;
  padding: 0 24px;
  font-size: 15px;
  border-radius: 12px;
}
.btn-block {
  width: 100%;
}
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  transition: all 0.16s;
}
.icon-btn:hover {
  background: var(--line-soft);
  color: var(--ink);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ---------------------------- 表单 ---------------------------- */
.field {
  display: block;
  margin-bottom: 14px;
}
.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field > span em {
  font-style: normal;
  color: var(--red);
}
.input,
.textarea,
.select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.6;
}
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}
.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex: none;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch i {
  position: absolute;
  inset: 0;
  background: #d0d5dd;
  border-radius: 99px;
  transition: 0.2s;
}
.switch i::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch input:checked + i {
  background: var(--brand);
}
.switch input:checked + i::after {
  transform: translateX(18px);
}

/* ---------------------------- 标签 / 徽标 ---------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--brand-soft);
  color: var(--brand-600);
  white-space: nowrap;
}
.tag.gray {
  background: #f2f4f7;
  color: var(--muted);
}
.tag.green {
  background: var(--green-soft);
  color: #067647;
}
.tag.amber {
  background: #fffaeb;
  color: #b54708;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  display: inline-block;
}
.dot.online {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.16);
}

/* ---------------------------- Toast ---------------------------- */
#toastWrap {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: #101828;
  color: #fff;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.22s ease both;
  max-width: 80vw;
}
.toast.ok::before {
  content: "✓";
  color: #6ce9a6;
  margin-right: 6px;
}
.toast.err {
  background: #b42318;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------------------------- 通用 ---------------------------- */
.empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 10px;
  padding: 40px;
  text-align: center;
}
.empty h4 {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--ink-2);
  font-weight: 600;
}
.empty p {
  margin: 0;
  font-size: 13px;
  max-width: 320px;
}
.empty .icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-xs);
  color: var(--brand);
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex: none;
  background: linear-gradient(135deg, #818cf8, #4f46e5);
  letter-spacing: 0.02em;
}
.hidden {
  display: none !important;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
