:root {
  --bg: #080b12;
  --bg-soft: #0d121c;
  --surface: #111825;
  --surface-2: #17202f;
  --border: #243043;
  --border-soft: #1b2434;
  --text: #e9eef8;
  --muted: #8d99ae;
  --muted-2: #6b778c;
  --accent: #ff6a3d;
  --accent-2: #ffb648;
  --accent-soft: rgba(255, 106, 61, 0.14);
  --ok: #34d399;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ---------- 登录页 ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(255, 106, 61, 0.16), transparent 60%),
    radial-gradient(800px 500px at 85% 90%, rgba(70, 120, 255, 0.14), transparent 60%),
    var(--bg);
}

.auth-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 40%, #000 30%, transparent 75%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 34px 32px 30px;
  background: rgba(17, 24, 37, 0.86);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  color: #14100c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px rgba(255, 106, 61, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 2px;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
}

.auth-card .brand {
  margin-bottom: 26px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: 0.5px;
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #1a120c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: transform 0.15s, filter 0.15s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-hint {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted-2);
  text-align: center;
}

.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  color: #ffd3cb;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.32);
}

/* ---------- 主页面 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
  padding: 0 22px;
  background: rgba(8, 11, 18, 0.86);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(16px);
}

.topbar .brand {
  flex: none;
  gap: 10px;
}

.topbar .brand-mark {
  width: 34px;
  height: 34px;
  font-size: 16px;
  border-radius: 9px;
}

.topbar .brand h1 {
  font-size: 15px;
  letter-spacing: 1.6px;
}

.topbar .brand p {
  font-size: 11px;
  letter-spacing: 0.6px;
}

.search-form {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 6px 0 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.search-form:focus-within {
  border-color: rgba(255, 106, 61, 0.65);
}

.search-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
}

.search-form input::placeholder {
  color: var(--muted-2);
}

.search-form button {
  height: 28px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 13px;
}

.user-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.3;
  margin-right: 2px;
}

.user-chip strong {
  font-size: 13px;
  font-weight: 600;
}

.user-chip small {
  font-size: 11px;
  color: var(--muted-2);
}

.ghost-btn {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}

.ghost-btn:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.sidebar {
  border-right: 1px solid var(--border-soft);
  padding: 18px 14px 40px;
  background: var(--bg-soft);
}

.sidebar-title {
  padding: 0 10px 10px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted-2);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 11px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 13px;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item small {
  margin-left: 8px;
  font-size: 10px;
  color: var(--muted-2);
}

.nav-item.active {
  background: var(--accent-soft);
  border-color: rgba(255, 106, 61, 0.35);
  color: var(--accent-2);
}

.nav-all {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  font-weight: 600;
}

.nav-all.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
}

.group {
  margin-top: 16px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 8px;
}

.group-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-2);
  letter-spacing: 1px;
}

.group-head span {
  font-size: 11px;
  color: var(--muted-2);
}

.group-items {
  display: flex;
  flex-direction: column;
}

.content {
  padding: 22px 26px 60px;
  min-width: 0;
}

.content-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.content-head h2 {
  margin: 0;
  font-size: 20px;
}

.content-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted-2);
}

.status-chip {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--accent-2);
  background: var(--accent-soft);
  border: 1px solid rgba(255, 106, 61, 0.28);
  white-space: nowrap;
  cursor: pointer;
}

.status-chip::after {
  content: "  ×";
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 106, 61, 0.55);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45);
}

.poster {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: linear-gradient(135deg, #1b2434, #0e131d);
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-size: 34px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle at 30% 20%, #233047, #0c111a);
}

.poster.no-poster img {
  display: none;
}

.poster.no-poster .poster-fallback {
  display: grid;
}

.poster-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.badge {
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.6;
  background: rgba(8, 11, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.badge.accent {
  color: var(--accent-2);
  border-color: rgba(255, 182, 72, 0.45);
}

.badge.douban {
  color: #ffd166;
  border-color: rgba(255, 209, 102, 0.4);
}

.card-body {
  padding: 10px 11px 12px;
}

.card-body h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-body p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted-2);
}

.loading,
.empty {
  padding: 70px 0;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 14px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.pager button {
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pager span {
  font-size: 12px;
  color: var(--muted);
}

.scroll-sentinel,
.scroll-end {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
  padding: 18px 0 28px;
  font-size: 12px;
  color: var(--muted-2);
}

.scroll-sentinel button {
  height: 34px;
  padding: 0 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.scroll-sentinel button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-2);
  color: var(--accent-2);
}

.scroll-sentinel button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 9, 0.72);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.modal-panel.wide {
  max-width: 1080px;
}

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

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--accent);
}

.movie-top {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 20px;
}

.player-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  align-self: start;
}

.player-wrap video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player-status {
  position: absolute;
  inset: auto 12px 12px 12px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
  color: #ffe3d9;
  background: rgba(6, 9, 14, 0.82);
  pointer-events: none;
}

.player-status:empty {
  display: none;
}

.movie-info {
  min-width: 0;
}

.info-head {
  display: flex;
  gap: 12px;
}

.info-cover {
  width: 84px;
  height: 112px;
  flex: none;
  border-radius: 10px;
  object-fit: cover;
  background: #0c111a;
  border: 1px solid var(--border);
}

.info-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
  word-break: break-word;
}

.info-head p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted-2);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.info-desc {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  max-height: 110px;
  overflow: auto;
  white-space: pre-wrap;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.meta-grid b {
  color: var(--muted-2);
  font-weight: 500;
}

.episode-area {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

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

.episode-head h3 {
  margin: 0;
  font-size: 14px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.action-row select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
}

.action-row button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
}

.action-row button:hover {
  border-color: var(--accent);
  color: var(--accent-2);
}

.action-row button.primary {
  border-color: rgba(255, 106, 61, 0.5);
  background: var(--accent-soft);
  color: var(--accent-2);
}

.episodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}

.ep-btn {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
}

.ep-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.ep-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 700;
}

.ep-btn.paid {
  color: #ffcf8a;
  border-color: rgba(255, 182, 72, 0.4);
}

.empty-episodes {
  padding: 16px 0;
  font-size: 12px;
  color: var(--muted-2);
}

/* ---------- 用户管理 ---------- */
.users-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-soft);
}

.users-form .field {
  margin: 0;
}

.users-form .field input,
.users-form .field select {
  height: 38px;
  background: var(--surface);
}

.users-form .form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}

.users-form .form-actions button {
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.users-form .form-actions button.primary {
  border-color: rgba(255, 106, 61, 0.5);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 600;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}

table.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  white-space: nowrap;
}

table.users-table th,
table.users-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

table.users-table th {
  color: var(--muted-2);
  font-weight: 500;
  background: var(--bg-soft);
}

table.users-table tr:last-child td {
  border-bottom: 0;
}

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.tag.ok {
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.4);
}

.tag.bad {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.4);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 12px;
}

.row-actions button:hover {
  border-color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 100;
  transform: translateX(-50%) translateY(16px);
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(23, 32, 47, 0.96);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 12px;
  }

  .search-form {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
  }

  .sidebar-title,
  .group-head {
    display: none;
  }

  .nav-all {
    width: auto;
    margin: 0;
    flex: none;
  }

  .group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
  }

  .group-items {
    flex-direction: row;
  }

  .nav-item {
    width: auto;
    margin: 0;
    flex: none;
  }

  .content {
    padding: 18px 16px 50px;
  }

  .movie-top {
    grid-template-columns: 1fr;
  }

  .modal-panel {
    padding: 16px;
    max-height: 94vh;
  }

  .users-form {
    grid-template-columns: 1fr;
  }
}
