:root {
  --bg: #0b1220;
  --panel: #0f172a;
  --surface: #0b1020;
  --card: #0f1b33;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --danger: #ef4444;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --font: "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, rgba(15,23,42,1) 0%, rgba(11,16,32,1) 100%);
  border-right: 1px solid var(--border);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: radial-gradient(120% 120% at 10% 10%, rgba(59,130,246,0.55), rgba(37,99,235,0.15));
  border: 1px solid rgba(59,130,246,0.25);
}

.sidebar-name { font-weight: 800; line-height: 1.1; }
.sidebar-sub { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

.sidebar-section {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px 10px 0;
}

.sidebar-nav { display: grid; gap: 8px; padding: 0 6px; }

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.side-link:hover {
  border-color: rgba(59,130,246,0.35);
  background: rgba(59,130,246,0.08);
}
.side-link.danger:hover {
  border-color: rgba(239,68,68,0.45);
  background: rgba(239,68,68,0.10);
}

.sidebar-spacer { flex: 1; }
.sidebar-footer { padding: 0 6px; display: grid; gap: 10px; }
.who { color: var(--muted); font-size: 0.875rem; }

.content {
  background: radial-gradient(1200px 700px at 20% 0%, rgba(59,130,246,0.10), transparent 55%),
              radial-gradient(800px 600px at 80% 10%, rgba(34,197,94,0.08), transparent 55%),
              var(--surface);
}

.content-top {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.72);
  backdrop-filter: blur(10px);
}

.crumb { color: var(--muted); font-size: 0.8rem; }
.title { font-size: 1.1rem; font-weight: 800; margin-top: 2px; }
.key-info { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.content-main {
  padding: 18px;
  max-width: 1200px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

h1 { margin: 0; font-size: 1.25rem; }

.table-wrap { overflow: visible; }
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.table th, .table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  font-size: 0.9rem;
}
.table th { color: var(--muted); font-weight: 700; background: rgba(255,255,255,0.03); }
.actions {
  text-align: right;
  white-space: nowrap;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
  font-size: 0.875rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: rgba(255,255,255,0.02); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,0.05); }
.btn-danger { background: var(--danger); color: #fff; }

.form { display: grid; gap: 10px; }
.form input, .form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  font-family: var(--font);
  background: rgba(255,255,255,0.02);
  color: var(--text);
}
.form input:focus, .form select:focus {
  outline: none;
  border-color: rgba(59,130,246,0.55);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.16);
}
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field.checkbox { align-content: end; }
.meta { display: grid; gap: 6px; margin-bottom: 10px; color: var(--muted); }
.hint { color: var(--muted); margin-top: 12px; font-size: 0.875rem; }
.error { color: var(--danger); font-weight: 800; }
.success { color: #22c55e; font-weight: 800; }

.auth-card { max-width: 440px; margin: 32px auto; }

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .grid { grid-template-columns: 1fr; }
  .table { min-width: 600px; }
}

/* 未登录：隐藏侧栏，让登录页更像后台入口 */
body.guest .sidebar { display: none; }
body.guest .layout { grid-template-columns: 1fr; }
body.guest .content-top { display: none; }
body.guest .content-main {
  max-width: 520px;
  margin: 0 auto;
  padding-top: 56px;
}

/* ======= 数据密度增强：统计/工具条/排序 ======= */
.content-main {
  max-width: 1600px;
}

.card-head.dense {
  margin-bottom: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search {
  width: min(520px, 60vw);
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.875rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.02);
}

.toggle input { width: 18px; height: 18px; }

.sorter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.02);
}

.sort-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
}

.sort-select {
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  font-weight: 800;
}

.sort-dir {
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.02);
  width: fit-content;
  color: var(--muted);
  font-weight: 800;
}

.inline-check input { width: 18px; height: 18px; }

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.btn-col {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  padding: 14px 14px 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stat .k {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.stat .v {
  margin-top: 6px;
  font-size: 1.25rem;
  font-weight: 900;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 12px;
  white-space: nowrap;
}

th.sortable::after {
  content: "⇅";
  display: inline-block;
  margin-left: 6px;
  color: rgba(148, 163, 184, 0.7);
  font-size: 0.8rem;
}

th.sortable.asc::after { content: "↑"; color: rgba(59,130,246,0.9); }
th.sortable.desc::after { content: "↓"; color: rgba(59,130,246,0.9); }

.pill-link {
  text-decoration: none;
  cursor: pointer;
}

.pill-link.danger {
  border-color: rgba(239,68,68,0.35);
  color: rgba(239,68,68,0.95);
}

.pill-link.danger:hover {
  background: rgba(239,68,68,0.12);
}

/* 套餐卡片 */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(15,23,42,0.95), rgba(15,23,42,0.88));
  padding: 18px 16px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.32);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-card--disabled {
  opacity: 0.65;
}

.plan-name {
  font-size: 1.05rem;
  font-weight: 800;
}

.plan-price {
  font-size: 1.4rem;
  font-weight: 900;
  color: #facc15;
}

.plan-duration {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 4px;
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: grid;
  gap: 4px;
  font-size: 0.88rem;
  color: var(--muted);
}

.plan-features li::before {
  content: "✔";
  display: inline-block;
  margin-right: 6px;
  color: #22c55e;
  font-size: 0.8rem;
}

.plan-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.plan-meta .status-pill {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* 封面预览：悬停时展示大图 */
.cover-preview {
  position: relative;
  display: inline-block;
}
.cover-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.16);
  color: #facc15;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: default;
}
.cover-preview-pop {
  position: absolute;
  left: 50%;
  bottom: 130%;
  transform: translateX(-50%) translateY(6px);
  padding: 6px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
  z-index: 40;
}
.cover-preview-pop img {
  max-width: 220px;
  max-height: 320px;
  display: block;
  border-radius: 10px;
}
.cover-preview:hover .cover-preview-pop {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.plan-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

@media (max-width: 768px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .search { width: 100%; }
}
