/* ===== 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);
}

/* ===== 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%;
  }
}
