/* ==========================================================================
   平台管理后台（PC）样式
   ========================================================================== */
:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #eff6ff;
  --bg: #f5f7fb;
  --card: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --sidebar: #111827;
  --sidebar-hover: #1f2937;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
[hidden] { display: none !important; }
a { color: var(--brand); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.flex-1 { flex: 1; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 2px 5px; font-size: 13px; border-radius: 4px; }
.link:hover { background: var(--brand-light); }
.link.danger { color: var(--danger); }
.link.danger:hover { background: var(--danger-bg); }
.link:disabled { color: var(--muted); cursor: not-allowed; background: none; }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; font-size: 14px; color: var(--text); background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.input[readonly], .input:disabled { background: #f8fafc; color: var(--muted); }
.textarea { resize: vertical; min-height: 70px; }

.chip { display: inline-block; font-size: 12px; line-height: 1.5; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.chip-ok { color: var(--ok); background: var(--ok-bg); }
.chip-warn { color: var(--warn); background: var(--warn-bg); }
.chip-danger { color: var(--danger); background: var(--danger-bg); }
.chip-muted { color: var(--muted); background: #f3f4f6; }
.chip-brand { color: var(--brand); background: var(--brand-light); }

/* ---------- 登录页 ---------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef2ff 0%, #f5f7fb 45%, #e0f2fe 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border-radius: 14px;
  padding: 34px 30px 26px; box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 16px 48px rgba(17,24,39,.10);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  background: linear-gradient(150deg, var(--brand), #7c3aed); color: #fff;
  font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.login-brand h1 { font-size: 20px; margin: 0 0 6px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.login-error {
  background: var(--danger-bg); color: var(--danger); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; margin-bottom: 14px;
}
.login-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: none; background: var(--sidebar); color: #e5e7eb;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; }
.side-logo {
  width: 34px; height: 34px; flex: none; border-radius: 9px;
  background: linear-gradient(150deg, var(--brand), #7c3aed); color: #fff;
  font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center;
}
.side-title b { display: block; font-size: 15px; color: #fff; }
.side-title i { display: block; font-style: normal; font-size: 12px; color: #9ca3af; margin-top: 1px; }
.side-nav { flex: 1; padding: 8px 10px; overflow-y: auto; }
.nav-item {
  display: block; color: #d1d5db; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; margin-bottom: 2px; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.side-foot { padding: 12px 18px 16px; font-size: 12px; color: #6b7280; }
.side-foot .ok { color: #34d399; }
.side-foot .bad { color: #f87171; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex: none; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 17px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; margin-right: 4px; }
.page { padding: 20px 22px 40px; flex: 1; }

/* ---------- 卡片 / 面板 ---------- */
.card {
  background: var(--card); border-radius: 12px; border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(17,24,39,.03);
  overflow: hidden;
}
.panel { padding: 18px 20px; margin-bottom: 16px; }
.panel h3 { font-size: 15px; margin: 0 0 10px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 130px; }
.toolbar .input { min-width: 200px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; letter-spacing: .5px; }
.stat-card .stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-card.ok .stat-value { color: var(--ok); }
.stat-card.warn .stat-value { color: var(--warn); }
.quick { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 12px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; background: #fafbfc; white-space: nowrap; }
.table tbody tr:hover { background: #f9fafb; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .ops { text-align: right; white-space: nowrap; }
.table .strong { font-weight: 600; }
.table .sub { color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-all; }
.empty { color: var(--muted); text-align: center; padding: 30px 0 !important; }
.empty.err { color: var(--danger); }

.pager { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pager .flex-1 { flex: 1; }

/* ---------- 详情键值 ---------- */
.kv { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv > span { flex: none; width: 110px; color: var(--muted); }
.kv > b { font-weight: 500; word-break: break-all; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); }
.field > span b { color: var(--danger); font-weight: 600; margin-left: 2px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; margin-top: 26px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.sub-fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 2px; margin: 4px 0 14px; }
.sub-fieldset legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
.check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 14px; }
.check-item { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; padding: 4px 0; }
.check-item input { margin-top: 3px; }
.check-item .desc { color: var(--muted); font-size: 12px; display: block; }
.hint { color: var(--muted); font-size: 12.5px; margin: -6px 0 12px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.48);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 20px 30px; z-index: 100; overflow-y: auto;
  animation: fadeIn .15s ease-out;
}
.modal {
  width: 100%; background: #fff; border-radius: 14px;
  box-shadow: 0 24px 64px rgba(15,23,42,.24);
  animation: popIn .18s ease-out;
  display: flex; flex-direction: column; max-height: 84vh;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.modal-x:hover { background: #f3f4f6; color: var(--text); }
.modal-body { padding: 16px 20px 4px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; }
.modal-foot .btn { min-width: 84px; }
.modal .dlg-text { margin: 0 0 6px; font-size: 14px; }
.modal .dlg-text .warn { color: var(--danger); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #111827; color: #fff; border-radius: 10px; padding: 9px 18px;
  font-size: 13.5px; box-shadow: 0 8px 24px rgba(15,23,42,.28);
  animation: fadeIn .18s ease-out; max-width: 70vw;
}
.toast-ok { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast.out { opacity: 0; transition: opacity .3s; }

/* ---------- 插件 ---------- */
.plugin-ops { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.depend-chip { margin-right: 4px; }

/* ---------- 窄屏兜底（管理端以 PC 为主，仅做基本兼容） ---------- */
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .side-title, .side-foot, .nav-item { font-size: 0; }
  .nav-item { text-align: center; }
  .nav-item::first-letter { font-size: 14px; }
  .grid2, .check-grid { grid-template-columns: 1fr; }
  .toolbar .input { min-width: 140px; }
}
