:root {
  color-scheme: dark;
  --bg: #050507;
  --panel: rgba(20, 21, 27, .78);
  --panel-solid: #121319;
  --muted: #a9adba;
  --text: #f8f8fb;
  --red: #e50914;
  --red-2: #ff3340;
  --line: rgba(255,255,255,.1);
  --shadow: 0 24px 80px rgba(0,0,0,.45);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% -10%, rgba(229,9,20,.2), transparent 34%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

.loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: #050507;
  transition: opacity .35s ease, visibility .35s ease;
}
.loader.hidden { opacity: 0; visibility: hidden; }
.loader span {
  width: 54px;
  height: 54px;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.navbar {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 4vw, 58px);
  background: linear-gradient(180deg, rgba(5,5,7,.96), rgba(5,5,7,.62));
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand, .auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}
.brand span, .auth-brand span {
  width: 12px;
  height: 32px;
  background: linear-gradient(180deg, var(--red), #8f050b);
  box-shadow: 0 0 26px rgba(229,9,20,.6);
}
.nav-actions { display: flex; align-items: center; gap: 18px; color: var(--muted); }
.nav-actions a:hover { color: #fff; }
.user-chip { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.04); color: #fff; }

.btn {
  border: 0;
  border-radius: var(--radius);
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  cursor: pointer;
  transition: transform .22s ease, box-shadow .22s ease, background .22s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: linear-gradient(135deg, var(--red), #9e0610); box-shadow: 0 12px 30px rgba(229,9,20,.28); }
.btn-ghost { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); }
.btn.tiny { padding: 8px 10px; font-size: 13px; }
.btn.danger { background: rgba(229,9,20,.18); color: #ffafb4; }
.hidden { display: none !important; }

.login-hero, .center-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 96px 20px 40px;
  background:
    linear-gradient(90deg, rgba(5,5,7,.94), rgba(5,5,7,.58)),
    url('../img/banner-placeholder.svg') center/cover;
}
.auth-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  background: rgba(14,15,20,.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.auth-card h1 { margin: 20px 0 8px; font-size: clamp(30px, 6vw, 48px); line-height: 1; }
.auth-card p, .muted { color: var(--muted); }
.form-stack, .admin-form { display: grid; gap: 16px; }
label { display: grid; gap: 8px; color: #d8dae2; font-weight: 650; }
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: rgba(255,255,255,.06);
  color: #fff;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(229,9,20,.7); box-shadow: 0 0 0 3px rgba(229,9,20,.15); }
.alert, .notice {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin: 10px 0 18px;
}
.alert { background: rgba(229,9,20,.14); border: 1px solid rgba(229,9,20,.35); color: #ffc6ca; }
.notice { background: rgba(60,180,110,.13); border: 1px solid rgba(60,180,110,.32); color: #c9ffd8; }

.hero {
  min-height: 82vh;
  display: flex;
  align-items: end;
  padding: 120px clamp(18px, 5vw, 70px) 70px;
  background-size: cover;
  background-position: center;
}
.hero-content { width: min(760px, 100%); animation: rise .7s ease both; }
.eyebrow { color: var(--red-2); text-transform: uppercase; font-weight: 800; font-size: 13px; letter-spacing: .08em; }
.hero h1, .detail-copy h1 { margin: 12px 0; font-size: clamp(42px, 8vw, 84px); line-height: .95; }
.hero p, .detail-copy p { color: #d5d7df; font-size: clamp(16px, 2vw, 20px); line-height: 1.65; }
.hero-meta, .hero-actions, .detail-actions, .tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.hero-meta span {
  color: #eceef5;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.hero-actions, .detail-actions { margin-top: 24px; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.catalog-shell, .catalog-section {
  padding: 28px clamp(18px, 5vw, 70px);
}
.filters-panel {
  position: sticky;
  top: 72px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(5, minmax(120px, 170px));
  gap: 12px;
  padding: 14px;
  margin-bottom: 22px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  background: rgba(10,11,15,.78);
  backdrop-filter: blur(16px);
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin: 10px 0 18px;
}
.section-title h2, .admin-head h1 { margin: 0; font-size: clamp(24px, 4vw, 36px); }
.section-title span { color: var(--muted); }
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 22px;
}
.movie-grid.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.movie-card {
  min-width: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.07);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.movie-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(229,9,20,.45);
  box-shadow: 0 22px 50px rgba(0,0,0,.5), 0 0 30px rgba(229,9,20,.16);
}
.poster-wrap {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #111;
}
.poster-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.movie-card:hover img { transform: scale(1.08); }
.card-overlay {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  gap: 5px;
  padding: 42px 14px 14px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.88));
  opacity: 0;
  transform: translateY(10px);
  transition: .25s ease;
}
.movie-card:hover .card-overlay { opacity: 1; transform: none; }
.card-overlay span, .card-body p { color: var(--muted); font-size: 13px; }
.card-body { padding: 12px; display: grid; gap: 8px; }
.card-body h3 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag {
  display: inline-flex;
  width: fit-content;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(229,9,20,.16);
  color: #ffd9dc;
  border: 1px solid rgba(229,9,20,.25);
  font-size: 12px;
  font-weight: 700;
}
.danger-tag { background: rgba(229,9,20,.28); }
.load-more-wrap { display: flex; justify-content: center; padding: 28px; }
.skeleton-card {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.11), rgba(255,255,255,.05));
  background-size: 240% 100%;
  animation: shimmer 1.2s ease infinite;
}
@keyframes shimmer { to { background-position: -240% 0; } }

.trailer-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.78);
  backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  transition: .25s ease;
}
.trailer-modal.active { opacity: 1; visibility: visible; }
.trailer-shell { position: relative; width: min(980px, 96vw); aspect-ratio: 16 / 9; box-shadow: var(--shadow); }
.trailer-shell iframe { width: 100%; height: 100%; border: 0; border-radius: var(--radius); background: #000; }
.modal-close { position: absolute; top: -46px; right: 0; width: 38px; height: 38px; border-radius: 50%; border: 0; color: #fff; background: var(--red); font-size: 26px; cursor: pointer; }

.detail-hero {
  min-height: 86vh;
  display: grid;
  grid-template-columns: minmax(210px, 330px) minmax(0, 760px);
  gap: clamp(24px, 5vw, 54px);
  align-items: end;
  padding: 130px clamp(18px, 5vw, 70px) 64px;
  background-size: cover;
  background-position: center;
}
.detail-poster { border-radius: var(--radius); box-shadow: var(--shadow); }
.detail-info {
  padding: 26px clamp(18px, 5vw, 70px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.detail-info div, .download-btn, .panel, .stat-card {
  border: 1px solid rgba(255,255,255,.09);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(14px);
}
.detail-info div { padding: 16px; display: grid; gap: 6px; }
.detail-info span { color: var(--muted); }
.download-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.download-btn { padding: 16px; display: grid; gap: 5px; transition: .22s ease; }
.download-btn:hover { transform: translateY(-3px); border-color: rgba(229,9,20,.45); }
.download-btn small { color: var(--muted); }
.rating-box { margin-top: 22px; display: flex; align-items: center; gap: 8px; }
.rating-box button { color: #595d6a; background: transparent; border: 0; font-size: 26px; cursor: pointer; }
.rating-box button:hover, .rating-box button.active { color: #ffd35a; }

.admin-layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; padding-top: 72px; }
.admin-sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  background: rgba(10,11,15,.9);
  border-right: 1px solid rgba(255,255,255,.08);
}
.admin-sidebar a:not(.brand) { padding: 12px; border-radius: var(--radius); color: var(--muted); }
.admin-sidebar a:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-main { padding: 28px clamp(18px, 4vw, 48px); }
.admin-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { padding: 18px; display: grid; gap: 8px; }
.stat-card span { color: var(--muted); }
.stat-card strong { font-size: 34px; }
.admin-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { padding: 18px; margin-bottom: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.panel h2 { margin-top: 0; }
.panel p { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.panel p strong { color: #fff; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.08); }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; }
.thumb { width: 46px; height: 68px; object-fit: cover; border-radius: 6px; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 14px; }
.checks label { display: flex; align-items: center; gap: 8px; }
.checks input { width: auto; }
.preview { width: 120px; height: 170px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.preview.wide { width: 220px; height: 120px; }
.server-row { display: grid; grid-template-columns: 180px 1fr; gap: 10px; margin-bottom: 10px; }
.admin-filter { position: static; grid-template-columns: 1fr 180px 120px; }
.url-cell { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 150;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #191b22;
  border: 1px solid rgba(229,9,20,.35);
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .navbar { height: auto; min-height: 70px; flex-wrap: wrap; gap: 10px; padding-block: 12px; }
  .nav-actions { width: 100%; overflow-x: auto; gap: 12px; font-size: 14px; }
  .filters-panel, .detail-info, .stat-grid, .admin-columns, .form-grid { grid-template-columns: 1fr; }
  .detail-hero { grid-template-columns: 1fr; padding-top: 150px; }
  .detail-poster { width: min(260px, 70vw); }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; }
}

@media (max-width: 560px) {
  .hero { min-height: 76vh; padding-top: 150px; }
  .movie-grid, .movie-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .card-body h3 { font-size: 14px; }
  .auth-card { padding: 24px; }
  .server-row { grid-template-columns: 1fr; }
  .section-title { align-items: start; flex-direction: column; }
}
