/* ===== Tokens ===== */
:root {
  --bg: #0c1117;
  --bg-elev: #141b24;
  --bg-soft: #1a2330;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eef6;
  --muted: #8b9aab;
  --accent: #3d9cf0;
  --accent-2: #2dd4bf;
  --danger: #f07178;
  --ok: #7fd99a;
  --warn: #e6c07b;
  --radius: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

/* ===== Auth ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 72px;
  position: relative;
  overflow-x: hidden;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 40% at 20% 20%, rgba(61, 156, 240, 0.22), transparent 60%),
    radial-gradient(ellipse 45% 35% at 80% 70%, rgba(45, 212, 191, 0.16), transparent 55%),
    linear-gradient(160deg, #0a0f15, #121a24 50%, #0c1117);
  animation: drift 18s ease-in-out infinite alternate;
  z-index: 0;
  pointer-events: none;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-2%, 2%, 0) scale(1.04); }
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  margin: 0 auto;
  padding: 36px 32px;
  background: rgba(20, 27, 36, 0.88);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.auth-brand {
  margin-bottom: 28px;
}

.auth-brand h1 {
  margin: 12px 0 6px;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #3d9cf0 0%, #2a7fd4 48%, #2dd4bf 100%);
  box-shadow: 0 8px 24px rgba(61, 156, 240, 0.35);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label,
.modal-body label {
  display: grid;
  gap: 8px;
}

.auth-form label span,
.modal-body label span {
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-form input,
.modal-body input,
.modal-body textarea,
.search-wrap input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-form input:focus,
.modal-body input:focus,
.modal-body textarea:focus,
.search-wrap input:focus {
  border-color: rgba(61, 156, 240, 0.55);
  box-shadow: 0 0 0 3px rgba(61, 156, 240, 0.18);
}

.modal-body textarea {
  resize: vertical;
  min-height: 84px;
}

.alert {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(240, 113, 120, 0.12);
  color: #ffb4b8;
  border: 1px solid rgba(240, 113, 120, 0.28);
}

.auth-links {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  z-index: 1;
  padding: 0 16px;
  text-align: center;
  animation: fade 0.7s ease both;
}

.auth-links ul {
  margin: 0 auto;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  max-width: 640px;
}

.auth-links a {
  color: var(--muted);
  font-size: 0.82rem;
  transition: color 0.2s;
}

.auth-links a:hover {
  color: var(--accent-2);
}

.site-author {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

.admin-footer {
  position: relative;
  z-index: 1;
  padding: 28px 16px 32px;
  text-align: center;
}

.admin-footer .site-author {
  margin: 0;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, border-color 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #3d9cf0, #2a7fd4);
  color: #fff;
  border-color: transparent;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.btn-block {
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(240, 113, 120, 0.3);
  background: rgba(240, 113, 120, 0.08);
}

.btn-danger:hover {
  background: rgba(240, 113, 120, 0.16);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

/* ===== Admin layout ===== */
.admin-page {
  min-height: 100vh;
  position: relative;
}

.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 40% 30% at 10% 0%, rgba(61, 156, 240, 0.14), transparent 60%),
    radial-gradient(ellipse 35% 25% at 90% 10%, rgba(45, 212, 191, 0.1), transparent 55%);
  z-index: 0;
}

.topbar,
.container {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 17, 23, 0.75);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-left strong {
  display: block;
  font-size: 1.05rem;
}

.topbar-left .muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.container {
  width: min(1180px, calc(100% - 40px));
  margin: 28px auto 48px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.stats {
  display: flex;
  gap: 10px;
}

.stat {
  min-width: 88px;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  animation: rise 0.45s ease both;
}

.stat span {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.stat label {
  color: var(--muted);
  font-size: 0.78rem;
}

.search-wrap {
  flex: 1;
  max-width: 320px;
  min-width: 200px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  position: sticky;
  top: 0;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: rgba(61, 156, 240, 0.05);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.name-cell {
  font-weight: 600;
}

.url-cell a {
  color: var(--accent-2);
  word-break: break-all;
}

.note-cell {
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid transparent;
}

.badge-on {
  color: var(--ok);
  background: rgba(127, 217, 154, 0.1);
  border-color: rgba(127, 217, 154, 0.25);
}

.badge-off {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px !important;
}

.clicks {
  font-variant-numeric: tabular-nums;
  color: var(--warn);
}

.id-pill {
  display: inline-block;
  min-width: 2rem;
  text-align: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ===== Modal ===== */
.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 12, 0.72);
  backdrop-filter: blur(4px);
  animation: fade 0.2s ease both;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  position: relative;
  width: min(460px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  animation: rise 0.28s ease both;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.modal-panel-about {
  width: min(520px, 100%);
}

.about-body {
  gap: 10px;
  line-height: 1.65;
  color: var(--text);
  font-size: 0.86rem;
}

.about-body p {
  margin: 0;
  color: #c5d0dc;
}

.about-body strong {
  color: var(--text);
  font-weight: 600;
}

.about-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(61, 156, 240, 0.12);
  color: var(--accent-2);
  font-size: 0.92em;
}

.about-points {
  margin: 0;
  padding: 10px 12px 10px 26px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: #c5d0dc;
  font-size: 0.84rem;
}

.about-points li + li {
  margin-top: 4px;
}

.about-tip {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.22);
  color: #b7efe4 !important;
  font-size: 0.84rem;
}

.about-links {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.about-links-title {
  margin: 0 0 8px !important;
  font-size: 0.78rem !important;
  color: var(--muted) !important;
  letter-spacing: 0.04em;
}

.about-links ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  background: none;
  border: none;
  text-align: left;
}

.about-links li {
  margin: 0;
  line-height: 1.4;
}

.about-links a {
  display: inline-block;
  color: var(--accent);
  font-size: 0.82rem;
  transition: color 0.2s;
}

.about-links a:hover {
  color: var(--accent-2);
}

.about-body .modal-foot {
  margin-top: 4px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 80;
  padding: 12px 18px;
  border-radius: 12px;
  background: #1e2a38;
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: var(--shadow);
  animation: rise 0.25s ease both;
}

.toast[hidden] {
  display: none;
}

.toast.ok {
  border-color: rgba(127, 217, 154, 0.35);
}

.toast.err {
  border-color: rgba(240, 113, 120, 0.4);
}

/* ===== Group tabs ===== */
.group-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.group-tabs .tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: color 0.15s, background 0.2s;
}
.group-tabs .tab:hover { color: var(--text); }
.group-tabs .tab-on {
  background: linear-gradient(135deg, #3d9cf0, #2a7fd4);
  color: #fff;
  border-color: transparent;
}

/* ===== Resource list ===== */
.res-list { display: grid; gap: 12px; }
.res-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  animation: rise 0.4s ease both;
}
.res-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  flex-wrap: wrap;
}
.expand-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  width: 20px;
  padding: 0;
}
.group-tag {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(61, 156, 240, 0.12);
  color: var(--accent);
  font-size: 0.75rem;
  border: 1px solid rgba(61, 156, 240, 0.22);
}
.res-name { font-weight: 600; font-size: 1rem; }
.res-meta {
  color: var(--muted);
  font-size: 0.82rem;
  flex: 1;
  min-width: 120px;
}
.res-pans {
  padding: 8px 16px 14px;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 8px;
}
.res-pans[hidden] { display: none; }
.pan-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--bg-soft);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.pan-badge {
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.pt-baidu  { background: #2b7fd4; }
.pt-quark  { background: #f0974a; }
.pt-xunlei { background: #8a6ad6; }
.pt-aliyun { background: #2dd4bf; }
.pt-pan123 { background: #5fae5f; }
.pt-189pc  { background: #d65f5f; }
.pt-lanzou { background: #3d8bd0; }
.pt-weiyun { background: #4aa3e8; }
.pt-other  { background: #6b7785; }
.pan-short {
  color: var(--accent-2);
  word-break: break-all;
  font-size: 0.82rem;
  flex: 1;
  min-width: 160px;
}
.pan-clicks {
  color: var(--warn);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.empty.small { padding: 14px; font-size: 0.85rem; }

/* ===== Wide / stats modal ===== */
.modal-panel-wide { width: min(620px, 100%); }
.modal-panel-stats { width: min(900px, 100%); }

/* ===== Pan link editor ===== */
.pan-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--bg-soft);
}
.pan-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.88rem;
  font-weight: 600;
}
.pan-list { display: grid; gap: 8px; }
.pan-edit-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pan-edit-row .pan-url-input { flex: 1; min-width: 120px; }
.pan-edit-row .pan-type-select {
  width: 130px;
  padding: 11px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.pan-edit-row .pan-type-select:focus {
  border-color: rgba(61, 156, 240, 0.55);
  box-shadow: 0 0 0 3px rgba(61, 156, 240, 0.18);
}
.pan-del-row {
  flex-shrink: 0;
  width: 38px;
  height: 42px;
  padding: 0;
  font-size: 1.2rem;
}
.pan-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ===== Group management ===== */
.group-add-row { display: flex; gap: 8px; }
.group-add-row input { flex: 1; }
.group-list { display: grid; gap: 8px; margin-top: 6px; }
.group-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.group-name { font-weight: 600; flex: 1; }
.group-cnt { color: var(--muted); font-size: 0.8rem; }

/* ===== Stats panel ===== */
.stats-body { max-height: 80vh; overflow: auto; }
.stats-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.scard {
  padding: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}
.scard span {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
}
.scard label {
  color: var(--muted);
  font-size: 0.78rem;
}
.stats-h {
  margin: 18px 0 10px;
  font-size: 0.9rem;
  color: var(--text);
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  padding: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.bar {
  flex: 1;
  background: linear-gradient(180deg, #3d9cf0, #2a7fd4);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.stats-block { min-width: 0; }
.ratio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.82rem;
}
.ratio-label {
  width: 90px;
  color: var(--muted);
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ratio-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.ratio-fill {
  height: 100%;
  background: linear-gradient(90deg, #2dd4bf, #3d9cf0);
  border-radius: 999px;
}
.ratio-num {
  width: 84px;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rank-list { display: grid; gap: 6px; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
}
.rank-no {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(61, 156, 240, 0.15);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}
.rank-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-num {
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .stats-cards { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
  .pan-edit-row { flex-wrap: wrap; }
  .pan-edit-row .pan-type-select { width: auto; flex: 1; }
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .topbar {
    padding: 14px 16px;
    flex-wrap: wrap;
  }

  .container {
    width: calc(100% - 24px);
    margin-top: 18px;
  }

  .stats {
    width: 100%;
  }

  .stat {
    flex: 1;
  }

  .search-wrap {
    max-width: none;
    width: 100%;
  }
}

/* 分组单选(radio 卡片) */
.field-group-radios{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}
.field-group-radios>.field-label{flex:0 0 auto;color:var(--muted,#9aa7b8);font-size:.85rem}
.radio-list{display:flex;flex-direction:row;flex-wrap:wrap;gap:.35rem}
.radio-list .radio-item{display:inline-flex;align-items:center;gap:.3rem;padding:.28rem .6rem;border:1px solid var(--line,rgba(255,255,255,.12));border-radius:.5rem;cursor:pointer;font-size:.85rem;user-select:none;white-space:nowrap}
.radio-list .radio-item input{width:auto;margin:0;accent-color:#3b82f6;cursor:pointer}
.radio-list .radio-item span{color:inherit;font-size:.85rem}
.radio-list .radio-item:has(input:checked){border-color:#3b82f6;background:rgba(59,130,246,.15)}

/* PanCheck 检测状态标识 */
.ck-badge{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;font-size:.7rem;font-weight:700;flex:0 0 auto;line-height:1}
.ck-ok{background:rgba(34,197,94,.18);color:#22c55e}
.ck-bad{background:rgba(239,68,68,.2);color:#ef4444}
.ck-pend{background:rgba(234,179,8,.2);color:#eab308}
.ck-none{background:rgba(148,163,184,.15);color:#64748b}
.pan-row.pan-bad{background:rgba(239,68,68,.08);border-color:rgba(239,68,68,.35)}
.scard-bad{border-color:rgba(239,68,68,.5);background:rgba(239,68,68,.1)}
.scard-bad span{color:#ef4444}
