/* ===== 设计系统 · 云痕统一登录 ===== */
:root {
  --bg: #f4f5f7;
  --bg-grad-1: #ffffff;
  --bg-grad-2: #eef1f4;
  --card: #ffffff;
  --card-2: #f7f8fa;
  --card-border: #e6e8ec;
  --text: #1c2128;
  --text-soft: #5b6470;
  --text-faint: #8a93a0;
  --primary: #0e7490;
  --primary-hover: #0c647a;
  --primary-soft: #e3f3f5;
  --primary-ink: #ffffff;
  --accent: #0e7490;
  --danger: #d6455b;
  --danger-soft: #fdeaee;
  --ok: #1f9d57;
  --ok-soft: #e6f6ec;
  --warn: #b7791f;
  --warn-soft: #fbf1dd;
  --info: #2f6fed;
  --info-soft: #e8effd;
  --shadow-sm: 0 1px 2px rgba(16, 22, 30, 0.05), 0 2px 6px rgba(16, 22, 30, 0.04);
  --shadow: 0 8px 24px rgba(16, 22, 30, 0.07);
  --shadow-lg: 0 16px 48px rgba(16, 22, 30, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --sidebar-w: 232px;
}

html.dark {
  --bg: #0e1116;
  --bg-grad-1: #141a22;
  --bg-grad-2: #0e1116;
  --card: #161a21;
  --card-2: #1b2029;
  --card-border: #262c37;
  --text: #e6e9ef;
  --text-soft: #94a0b2;
  --text-faint: #67707f;
  --primary: #2dd4bf;
  --primary-hover: #14b8a6;
  --primary-soft: #12302e;
  --primary-ink: #04201d;
  --accent: #2dd4bf;
  --danger: #f87185;
  --danger-soft: #3a2026;
  --ok: #4ade80;
  --ok-soft: #173a26;
  --warn: #fbbf24;
  --warn-soft: #3a2e16;
  --info: #60a5fa;
  --info-soft: #1a2b40;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 620px at 50% -12%, var(--bg-grad-1), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ===== 顶部栏 ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--card) 72%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--card-border);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--primary);
  color: #fff; display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.brand .logo svg { width: 20px; height: 20px; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ===== 图标按钮 ===== */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--card-border);
  color: var(--text-soft); cursor: pointer; transition: .18s;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.icon-btn svg { width: 19px; height: 19px; }

.avatar {
  width: 52px; height: 52px; border-radius: 15px; flex: none;
  background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: 21px; font-weight: 800;
  box-shadow: var(--shadow-sm);
}

/* ===== 通用卡片 ===== */
.container { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 26px 16px; }
.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px; width: 100%; max-width: 440px;
}
.card.wide { max-width: 960px; }
.footer { text-align: center; color: var(--text-faint); font-size: 12.5px; padding: 18px; }

h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: .2px; }
h2 { font-size: 17px; margin: 0 0 14px; }
h3 { font-size: 14px; margin: 0; }
.sub { color: var(--text-soft); font-size: 14px; margin-bottom: 18px; line-height: 1.6; }

/* ===== 表单 ===== */
label { display: block; font-size: 13px; margin: 14px 0 6px; color: var(--text-soft); font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--card-border); background: var(--card-2);
  color: var(--text); font-size: 14px; outline: none; transition: .15s; font-family: inherit;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); background: var(--card);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border: none; border-radius: var(--radius-sm);
  background: var(--primary); color: var(--primary-ink); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .15s; line-height: 1; white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn svg { width: 16px; height: 16px; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--card-border); }
.btn.ghost:hover { background: var(--primary-soft); border-color: transparent; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.05); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 16px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

/* ===== 徽章 ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary);
}
.badge svg { width: 12px; height: 12px; }
.badge.muted { background: var(--card-border); color: var(--text-soft); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* ===== 提示信息 ===== */
.msg { font-size: 13px; margin-top: 12px; min-height: 18px; line-height: 1.5; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* ===== 代码框 ===== */
.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--card-2); border: 1px dashed var(--card-border);
  border-radius: var(--radius-sm); padding: 12px 14px; word-break: break-all;
  font-size: 12.5px; line-height: 1.7; color: var(--text-soft); white-space: pre-wrap;
}

/* ===== 表格 ===== */
.table-wrap { border: 1px solid var(--card-border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 12px 16px; color: var(--text-soft); font-weight: 600; font-size: 12px;
  background: var(--card-2); border-bottom: 1px solid var(--card-border); letter-spacing: .3px;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--card-border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--primary-soft); }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-soft { color: var(--text-soft); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.nowrap { white-space: nowrap; }

/* ===== Toast ===== */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 11px 16px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--card-border); box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 500; color: var(--text);
  animation: toastIn .22s ease; max-width: 90vw;
}
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.ok { border-color: var(--ok); } .toast.ok svg { color: var(--ok); }
.toast.err { border-color: var(--danger); } .toast.err svg { color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== 空状态 ===== */
.empty { text-align: center; padding: 40px 20px; color: var(--text-faint); }
.empty svg { width: 42px; height: 42px; opacity: .5; margin-bottom: 10px; }

/* ===== 分隔 / 小节标题 ===== */
.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; }
.section-title .line { flex: 1; height: 1px; background: var(--card-border); }

/* ===== 网格 ===== */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 860px) { .grid4 { grid-template-columns: repeat(2, 1fr); } .grid3 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .grid2, .grid4 { grid-template-columns: 1fr; } }

/* ===== 后台布局 ===== */
.admin-shell { display: flex; min-height: calc(100vh - 67px); width: 100%; }
.sidebar {
  width: var(--sidebar-w); flex: none; padding: 18px 14px;
  border-right: 1px solid var(--card-border);
  background: color-mix(in srgb, var(--card) 60%, transparent);
  position: sticky; top: 67px; align-self: flex-start; height: calc(100vh - 67px);
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar .nav-group { font-size: 11px; color: var(--text-faint); font-weight: 700; letter-spacing: .6px; padding: 14px 12px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px;
  color: var(--text-soft); cursor: pointer; font-size: 14px; font-weight: 500; transition: .15s;
  border: 1px solid transparent; user-select: none;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.nav-item.active svg { color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .nav-foot { font-size: 11.5px; color: var(--text-faint); padding: 10px 12px; line-height: 1.5; }

.admin-main { flex: 1; padding: 26px 30px; min-width: 0; }
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.admin-head .title h1 { margin-bottom: 2px; }
.admin-head .title .crumb { font-size: 12.5px; color: var(--text-faint); }
@media (max-width: 760px) {
  .admin-shell { flex-direction: column; }
  .sidebar { width: 100%; position: static; height: auto; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--card-border); }
  .sidebar .nav-group, .sidebar .spacer, .sidebar .nav-foot { display: none; }
  .admin-main { padding: 18px 16px; }
}

/* ===== 统计卡片 ===== */
.stat-card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 14px; transition: .18s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-ico {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex: none;
}
.stat-card .stat-ico svg { width: 23px; height: 23px; }
.stat-ico.i-primary { background: var(--primary-soft); color: var(--primary); }
.stat-ico.i-ok { background: var(--ok-soft); color: var(--ok); }
.stat-ico.i-info { background: var(--info-soft); color: var(--info); }
.stat-ico.i-accent { background: var(--warn-soft); color: var(--warn); }
.stat-meta .stat-num { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: .5px; }
.stat-meta .stat-label { font-size: 12.5px; color: var(--text-soft); margin-top: 4px; }

/* ===== 工具条（搜索 + 操作） ===== */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; }
.toolbar .search input { padding-left: 36px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); }
.icon-sm-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--card-border); background: var(--card); color: var(--text-soft); cursor: pointer; transition: .15s;
}
.icon-sm-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-sm-btn svg { width: 15px; height: 15px; }
.btn-icon-text { display: inline-flex; align-items: center; gap: 7px; }

/* ===== 模态框 ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12, 14, 22, 0.5); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 200; padding: 16px; animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; padding: 24px; animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
.modal .modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ===== 主题色色板 ===== */
.swatch-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px 8px; }
.swatch-cell {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; padding: 4px 2px; border-radius: var(--radius-sm);
  transition: .15s;
}
.swatch-cell:hover { background: var(--card-2); }
.swatch-dot {
  position: relative; width: 30px; height: 30px; border-radius: 50%;
  box-shadow: var(--shadow-sm); border: 2px solid transparent; transition: .15s;
}
.swatch-cell:hover .swatch-dot { transform: translateY(-2px); }
.swatch-cell.active .swatch-dot { border-color: var(--text); box-shadow: 0 0 0 3px var(--primary-soft); }
.swatch-check {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
}
.swatch-check svg { width: 16px; height: 16px; }
.swatch-name { font-size: 11px; color: var(--text-soft); line-height: 1.1; text-align: center; }
.swatch-cell.active .swatch-name { color: var(--text); font-weight: 600; }

.theme-preview {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft);
  margin-bottom: 16px; padding: 10px 12px; background: var(--card-2);
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
}
.theme-preview b { color: var(--text); font-weight: 600; }
.theme-preview svg { width: 15px; height: 15px; color: var(--primary); }
.theme-hex { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--text-faint); }

.custom-color {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 10px 12px;
  background: var(--card-2); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-soft); cursor: pointer;
}
.custom-color svg { width: 16px; height: 16px; color: var(--primary); }
.custom-color .color-custom {
  margin-left: auto; width: 38px; height: 28px; padding: 0; border: 1px solid var(--card-border);
  border-radius: 8px; background: none; cursor: pointer;
}
.custom-color .color-custom::-webkit-color-swatch-wrapper { padding: 2px; }
.custom-color .color-custom::-webkit-color-swatch { border: none; border-radius: 6px; }

/* ===== View Transitions（暗色切换圆形扩散，借鉴 ElainaBot） ===== */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* ===== 行内加载 ===== */
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; align-items: center; gap: 10px; color: var(--text-soft); font-size: 14px; padding: 30px; justify-content: center; }

/* ===== 授权页 / 登录页个人头像圆形 ===== */
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 26px; }
.hero-brand .logo { width: 46px; height: 46px; border-radius: 14px; background: var(--primary); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.hero-brand .logo svg { width: 26px; height: 26px; color: #fff; }
.hero-brand .t1 { font-size: 19px; font-weight: 800; }
.hero-brand .t2 { font-size: 12.5px; color: var(--text-soft); }
