/* ==========================================================================
   管理后台样式
   ========================================================================== */
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --ink-2: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --sidebar: #111827;
  --sidebar-2: #1f2937;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: var(--brand); text-decoration: none; }
button { font: inherit; }
[hidden] { display: none !important; }

/* ---------------------------------- 登录 --------------------------------- */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 10% -10%, #dbeafe 0%, transparent 55%),
    radial-gradient(900px 500px at 110% 110%, #ede9fe 0%, transparent 55%),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 22px; color: var(--ink-2); font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: #f9fafb; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.danger { color: var(--danger); border-color: #fecaca; background: #fff5f5; }
.btn.danger:hover { background: #fee2e2; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: #f3f4f6; color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.block { width: 100%; }

/* ---------------------------------- 布局 --------------------------------- */
#app { display: flex; min-height: 100%; }
.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  color: #fff;
  font-weight: 600;
  letter-spacing: .5px;
}
.brand .dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-2), #22d3ee);
  display: grid; place-items: center;
  font-size: 14px;
}
.nav { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 14px;
}
.nav a:hover { background: var(--sidebar-2); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sidebar-foot .who { color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot button {
  background: transparent; color: #94a3b8; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.sidebar-foot button:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 22px;
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 18px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 20px 22px 40px; }

/* ---------------------------------- 卡片 --------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--ink-2); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: .5px; }
.stat .hint { color: var(--ink-2); font-size: 12px; margin-top: 4px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-body { padding: 14px 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .input { width: 220px; }
.muted { color: var(--ink-2); }

/* ---------------------------------- 表格 --------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f9fafb; color: var(--ink-2); font-weight: 500; font-size: 12.5px; position: sticky; top: 0; }
tbody tr:hover { background: #f9fafb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-2); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; line-height: 18px; border: 1px solid transparent;
}
.badge.ok { background: #ecfdf5; color: var(--ok); border-color: #a7f3d0; }
.badge.warn { background: #fffbeb; color: var(--warn); border-color: #fde68a; }
.badge.bad { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.badge.info { background: #eef2ff; color: var(--brand); border-color: #c7d2fe; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover; object-position: top center;
  background: #e5e7eb; vertical-align: middle; margin-right: 8px;
}

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }

/* ---------------------------------- 弹窗 --------------------------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  width: 100%; max-width: 520px; max-height: 86vh; overflow: auto;
  background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head button { border: 0; background: transparent; font-size: 20px; line-height: 1; color: var(--ink-2); cursor: pointer; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------------------------------- 提示 --------------------------------- */
#toast {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none;
}
.toast-item {
  background: #111827; color: #fff; padding: 9px 14px; border-radius: 8px;
  box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(-6px);
  transition: opacity .18s, transform .18s;
}
.toast-item.show { opacity: 1; transform: translateY(0); }
.toast-item.err { background: var(--danger); }

/* ------------------------------- 空视图/加载 ------------------------------ */
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef0f4 25%, #f6f7f9 37%, #eef0f4 63%); background-size: 400% 100%; animation: sk 1.2s ease infinite; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --------------------------------- 响应式 -------------------------------- */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; overflow: auto; }
  .brand { padding: 12px 14px; white-space: nowrap; }
  .nav { flex-direction: row; padding: 6px; overflow: auto; }
  .nav a { white-space: nowrap; padding: 7px 10px; }
  .sidebar-foot { border-top: 0; white-space: nowrap; }
  .content { padding: 14px; }
  .topbar { padding: 12px 14px; }
}
