:root {
  --bg: #0f0f12;
  --surface: #1a1a20;
  --surface-2: #24242c;
  --border: #2e2e38;
  --text: #ececf1;
  --muted: #9a9aa8;
  --accent: #ff6a00;
  --accent-hover: #ff8533;
  --good: #3bb33b;
  --mid: #c9a227;
  --bad: #d64545;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ---------- Шапка ---------- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.header .container { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.nav { display: flex; gap: 20px; }
.nav a { color: var(--muted); font-weight: 500; transition: color .2s; }
.nav a:hover, .nav a.active { color: var(--text); }

main { flex: 1; padding: 32px 0 48px; }

.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }

h1 { font-size: 32px; margin-bottom: 20px; }
h2 { font-size: 22px; margin-bottom: 16px; }

/* ---------- Формы и кнопки ---------- */
input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  width: 100%;
  outline: none;
  transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.97); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #e55; }
.btn-sm { padding: 6px 12px; font-size: 14px; }

/* ---------- Фильтры ---------- */
.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}

/* ---------- Сетка карточек ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 22px;
}
.card { display: block; transition: transform .2s; }
.card:hover { transform: translateY(-4px); }
.card:hover .poster { box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.card-title { font-weight: 600; margin-top: 10px; }
.card-meta { color: var(--muted); font-size: 14px; }

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  transition: box-shadow .2s;
}
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster-placeholder {
  font-size: 22px; font-weight: 800; text-align: center; padding: 16px;
  color: rgba(255,255,255,.92); text-shadow: 0 2px 8px rgba(0,0,0,.4);
}

/* ---------- Рейтинг ---------- */
.rating {
  display: inline-block;
  min-width: 38px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  background: var(--surface-2);
  color: var(--muted);
}
.rating.good { background: var(--good); color: #fff; }
.rating.mid  { background: var(--mid);  color: #fff; }
.rating.bad  { background: var(--bad);  color: #fff; }
.poster .rating { position: absolute; top: 8px; left: 8px; }

/* ---------- Страница тайтла ---------- */
.title-page { display: grid; grid-template-columns: 300px 1fr; gap: 40px; }
.title-info h1 { margin-bottom: 8px; }
.title-sub { color: var(--muted); margin-bottom: 20px; }
.big-rating { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.big-rating .rating { font-size: 28px; padding: 6px 14px; }
.facts { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin-bottom: 24px; }
.facts dt { color: var(--muted); }
.description { font-size: 17px; max-width: 700px; }

.section { margin-top: 48px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* Выбор оценки 1–10 */
.stars { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.stars button {
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.stars button.on { background: var(--accent); border-color: var(--accent); }

.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.reviews { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.review { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.review-author { font-weight: 600; }
.review-date { color: var(--muted); font-size: 13px; margin-left: auto; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.error-msg { color: var(--bad); font-size: 14px; margin-top: 8px; min-height: 20px; }

/* ---------- Админка ---------- */
.login-box { max-width: 360px; margin: 60px auto; }
.admin-layout { display: grid; grid-template-columns: 380px 1fr; gap: 28px; align-items: start; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 14px; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tabs .btn.active { background: var(--accent); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 12px 20px; border-radius: 8px;
  transition: transform .3s; z-index: 100;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Адаптивность ---------- */
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .title-page { grid-template-columns: 1fr; }
  .title-page .poster { max-width: 260px; }
}
@media (max-width: 640px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
  .nav { gap: 14px; }
}
