/* =========================================================
   槿篱游戏库 · 管理后台样式
   ========================================================= */

:root {
  --bg: #090807;
  --surface: #12100c;
  --surface-2: #17140f;
  --surface-3: #1c1811;
  --line: rgba(214, 175, 102, 0.13);
  --line-strong: rgba(214, 175, 102, 0.32);
  --gold: #d6af66;
  --gold-strong: #efd194;
  --ink: #f0ebdf;
  --ink-soft: #d5cebf;
  --muted: #968e7f;
  --muted-2: #6d665a;
  --green: #86c58d;
  --red: #e0806f;
  --radius: 13px;
  --display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --sans: "Inter", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
h1, h2, h3, h4, p { margin: 0; }
img { max-width: 100%; display: block; }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #f3d99d, #c5973f 60%, #a97a2c);
  color: #201607;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 8px 22px -12px rgba(214, 175, 102, 0.8);
  flex-shrink: 0;
}

/* ------------------------------ login ------------------------------ */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 540px at 20% 0%, rgba(190, 140, 55, 0.16), transparent 60%),
    radial-gradient(700px 500px at 92% 100%, rgba(120, 82, 22, 0.1), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 402px;
  background: linear-gradient(170deg, #14110c, #0c0a08);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px;
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.9);
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand strong { display: block; font-family: var(--display); font-size: 16px; }
.login-brand em { display: block; font-style: normal; font-size: 8.5px; letter-spacing: 0.2em; color: var(--muted-2); margin-top: 2px; }
.login-card h1 { font-family: var(--display); font-size: 24px; font-weight: 700; margin-top: 26px; }
.login-desc { font-size: 12px; color: var(--muted); line-height: 1.8; margin-top: 8px; }
.login-field { display: block; margin-top: 18px; }
.login-field span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 7px; }
.login-field input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0c0a08;
  color: var(--ink);
  padding: 0 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
}
.login-field input:focus { border-color: rgba(214, 175, 102, 0.5); }
.login-hint { font-size: 11px; color: var(--muted-2); margin-top: 16px; line-height: 1.8; text-align: center; }
.login-hint b { color: var(--gold); font-weight: 600; }
.login-back { display: block; text-align: center; font-size: 11.5px; color: var(--muted-2); margin-top: 18px; }
.login-back:hover { color: var(--gold); }
.btn-block { width: 100%; margin-top: 24px; }

/* ------------------------------ shell ------------------------------ */

.admin-shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 14px;
  background: #0b0a08;
  border-right: 1px solid var(--line);
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.side-brand strong { display: block; font-family: var(--display); font-size: 14.5px; }
.side-brand em { display: block; font-style: normal; font-size: 8px; letter-spacing: 0.18em; color: var(--muted-2); margin-top: 2px; }
.side-brand .brand-mark { width: 36px; height: 36px; font-size: 19px; }

.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #b8b0a0;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
}
.side-nav button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; flex-shrink: 0; opacity: 0.8; }
.side-nav button:hover { background: rgba(255, 255, 255, 0.035); color: var(--ink-soft); }
.side-nav button.active {
  background: rgba(214, 175, 102, 0.11);
  border-color: rgba(214, 175, 102, 0.16);
  color: var(--gold-strong);
}
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 6px 0; border-top: 1px solid var(--line); }
.side-foot a, .side-foot button {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  padding: 7px 4px;
  cursor: pointer;
}
.side-foot a:hover, .side-foot button:hover { color: var(--gold); }

.admin-main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 9, 8, 0.86);
  backdrop-filter: blur(14px);
}
.topbar h1 { font-family: var(--display); font-size: 21px; font-weight: 700; }
.topbar p { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.admin-user { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; }
.admin-user::before { content: "●"; color: var(--green); font-size: 8px; margin-right: 6px; vertical-align: 1px; }

.view { padding: 24px 26px 60px; max-width: 1480px; width: 100%; }

/* ------------------------------ buttons ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #f0d698, #d3a74f 55%, #bd8c37);
  color: #241a08;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-ghost { border-color: var(--line); color: var(--ink-soft); background: rgba(255, 255, 255, 0.02); }
.btn-ghost:hover { border-color: var(--line-strong); color: var(--gold-strong); }
.btn-danger { border-color: rgba(224, 128, 111, 0.35); color: #eaa196; background: rgba(224, 128, 111, 0.06); }
.btn-danger:hover { background: rgba(224, 128, 111, 0.13); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 11.5px; border-radius: 6px; font-weight: 500; }

/* ------------------------------ stats ------------------------------ */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: linear-gradient(160deg, #14110c, #0d0b08);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -46px;
  width: 130px;
  height: 130px;
  background: radial-gradient(circle, rgba(214, 175, 102, 0.14), transparent 70%);
}
.stat-card span { font-size: 11px; color: var(--muted-2); letter-spacing: 0.08em; }
.stat-card strong { display: block; font-family: var(--display); font-size: 30px; font-weight: 700; margin-top: 6px; color: var(--ink); }
.stat-card em { display: block; font-style: normal; font-size: 10.5px; color: var(--muted-2); margin-top: 4px; }

.panel-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 14px; margin-top: 16px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.panel-head a { font-size: 11.5px; color: var(--gold); }

.bar-row { display: grid; grid-template-columns: 82px 1fr 34px; align-items: center; gap: 10px; margin-bottom: 11px; font-size: 11.5px; color: var(--muted); }
.bar-track { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.05); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, rgba(214, 175, 102, 0.55), var(--gold)); }
.bar-row b { text-align: right; color: var(--muted-2); font-weight: 500; }

/* ------------------------------ toolbar ------------------------------ */

.admin-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 14px; }
.admin-toolbar .spacer { flex: 1; }
.input, .select, .textarea {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0a08;
  color: var(--ink);
  font-size: 12.5px;
  padding: 0 11px;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus, .select:focus, .textarea:focus { border-color: rgba(214, 175, 102, 0.48); }
.select { cursor: pointer; }
.search-input { position: relative; display: flex; align-items: center; }
.search-input input { width: 260px; padding-left: 33px; }
.search-input svg { position: absolute; left: 10px; width: 14px; height: 14px; stroke: var(--muted-2); fill: none; stroke-width: 1.8; }
.textarea { height: auto; padding: 10px 11px; resize: vertical; line-height: 1.7; width: 100%; }

/* ------------------------------ tables ------------------------------ */

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
thead th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--muted-2);
  padding: 11px 14px;
  background: #0f0d0a;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid rgba(214, 175, 102, 0.07); font-size: 12.5px; color: var(--muted); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(214, 175, 102, 0.035); }
td.strong { color: var(--ink-soft); font-weight: 500; }
td .cell-title { display: flex; align-items: center; gap: 11px; min-width: 180px; }
td .cell-title img { width: 38px; height: 50px; object-fit: cover; border-radius: 5px; background: #1a1610; flex-shrink: 0; }
td .cell-title .t-name { color: var(--ink-soft); font-weight: 500; font-size: 13px; }
td .cell-title .t-sub { color: var(--muted-2); font-size: 10.5px; margin-top: 2px; }
.thumb-wide { width: 92px; height: 50px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-empty { padding: 50px 20px; text-align: center; color: var(--muted-2); font-size: 12.5px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.green { color: #a7d6ac; border-color: rgba(134, 197, 141, 0.3); background: rgba(134, 197, 141, 0.07); }
.badge.gray { color: var(--muted-2); }
.badge.gold { color: var(--gold); border-color: rgba(214, 175, 102, 0.3); background: rgba(214, 175, 102, 0.07); }
.badge.red { color: #eaa196; border-color: rgba(224, 128, 111, 0.3); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; font-size: 11.5px; color: var(--muted-2); flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; }
.pager button {
  min-width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--line-strong); color: var(--gold); }
.pager button:disabled { opacity: 0.35; cursor: not-allowed; }

/* ------------------------------ modal ------------------------------ */

.modal-root { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 28px; background: rgba(4, 3, 2, 0.72); backdrop-filter: blur(6px); }
.modal {
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #100d09;
  border: 1px solid rgba(214, 175, 102, 0.22);
  border-radius: 16px;
  box-shadow: 0 50px 100px -40px rgba(0, 0, 0, 0.95);
  overflow: hidden;
  animation: modal-in 0.2s ease;
}
.modal.wide { max-width: 900px; }
.modal.confirm { max-width: 420px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-family: var(--display); font-size: 17px; font-weight: 700; }
.modal-close { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--gold); border-color: var(--line-strong); }
.modal-body { padding: 20px 22px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 22px; border-top: 1px solid var(--line); background: #0d0b08; }
.modal-text { font-size: 13px; color: var(--muted); line-height: 1.8; }
.modal-text b { color: var(--ink-soft); }

/* ------------------------------ forms ------------------------------ */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field.full { grid-column: 1 / -1; }
.form-field > span { font-size: 11px; color: var(--muted); letter-spacing: 0.03em; }
.form-field > span b { color: var(--gold); }
.form-field input, .form-field select, .form-field textarea {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0a08;
  color: var(--ink);
  font-size: 12.5px;
  padding: 0 10px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}
.form-field textarea { height: auto; padding: 9px 10px; resize: vertical; line-height: 1.7; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: rgba(214, 175, 102, 0.48); }
.form-field small { font-size: 10px; color: var(--muted-2); line-height: 1.7; }
.form-section { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: 0.12em; color: var(--gold); margin-top: 6px; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.check-row { display: flex; flex-wrap: wrap; gap: 7px; }
.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s;
  user-select: none;
}
.check-chip input { accent-color: #c99a3f; width: 12px; height: 12px; margin: 0; }
.check-chip:has(input:checked) { border-color: rgba(214, 175, 102, 0.5); color: var(--gold-strong); background: rgba(214, 175, 102, 0.08); }
.check-line { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); cursor: pointer; }
.check-line input { accent-color: #c99a3f; }

.upload-row { display: flex; gap: 8px; }
.upload-row input[type="text"] { flex: 1; }
.file-btn { position: relative; overflow: hidden; flex-shrink: 0; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ------------------------------ settings ------------------------------ */

.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.settings-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 20px; }
.settings-card.full { grid-column: 1 / -1; }
.settings-card h2 { font-family: var(--display); font-size: 16px; margin-bottom: 16px; }
.settings-card .form-grid { gap: 12px; }
.settings-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }

/* ------------------------------ toast / misc ------------------------------ */

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: 320px; }
.toast {
  padding: 11px 15px;
  border-radius: 9px;
  border: 1px solid rgba(214, 175, 102, 0.3);
  background: #19150e;
  color: var(--ink-soft);
  font-size: 12px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
  animation: toast-in 0.22s ease;
}
.toast.success { border-color: rgba(134, 197, 141, 0.4); color: #b9ddbd; }
.toast.error { border-color: rgba(224, 128, 111, 0.45); color: #efb3a8; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.loading { padding: 60px 0; display: flex; justify-content: center; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(214, 175, 102, 0.16); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }

/* ------------------------------ responsive ------------------------------ */

@media (max-width: 1000px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .side-brand { min-width: max-content; }
  .side-nav { flex-direction: row; gap: 2px; }
  .side-nav button { width: auto; white-space: nowrap; }
  .side-nav button svg { display: none; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; border-top: 0; padding: 0; min-width: max-content; }
  .side-foot a { display: none; }
  .view { padding: 20px 16px 50px; }
  .topbar { padding: 14px 16px; }
  .panel-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .search-input input { width: 100%; }
  .search-input { flex: 1; min-width: 0; }
  .admin-toolbar .search-input { flex: 1 1 100%; }
  .topbar p { display: none; }
  .admin-user { display: none; }
  .modal-root { padding: 12px; }
  .modal-body { padding: 16px; }
}

/* ---------------------------- box images ---------------------------- */

.box-img-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 18px; }
.box-img-item { display: flex; flex-direction: column; gap: 10px; }
.box-img-label { font-size: 12px; color: var(--muted); }
.box-img-preview { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border: 1px solid var(--line); border-radius: 10px; background: #0d0b09; }
.box-img-upload { align-self: flex-start; cursor: pointer; }
.box-visible-toggle { display: flex; align-items: center; gap: 10px; margin: 12px 0 16px; font-size: 13px; color: var(--text); cursor: pointer; }
.box-visible-toggle input { width: 16px; height: 16px; accent-color: var(--gold); cursor: pointer; }
.box-count { font-size: 11px; color: var(--gold); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-family: var(--sans); font-weight: normal; vertical-align: middle; }
.box-plan-edit { border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.015); padding: 16px; margin-bottom: 14px; }
.box-plan-edit-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.box-plan-edit-head strong { font-size: 13px; color: var(--gold); }
.box-plan-flags { display: flex; align-items: center; gap: 16px; }
.box-plan-edit .form-row { margin-top: 12px; }
.upstream-status { margin: 12px 0 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,0.02); font-size: 13px; line-height: 1.9; }
.upstream-status p { margin: 0; }
.upstream-running { color: var(--gold); }
.upstream-error { color: #ff8a80; }
.upstream-result { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #0d0b09; font-size: 12.5px; line-height: 1.9; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 1100px) {
  .box-img-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .box-img-grid { grid-template-columns: 1fr; }
}
