@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #b82323; 
  --primary-dark: #8a1616;
  --accent-gold: #f5c451;
  --accent-gold-dark: #c28b38;
  --bg: #fcfaf5;
  --card-bg: #ffffff;
  --text: #2c2a27;
  --text-muted: #7d7a75;
  --border: #e6e1d6;
  --danger: #d94a4a;
}

body {
  font-family: 'Montserrat', -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* =========================================================
   ЭКРАН ГОЛОСОВАНИЯ (МОБИЛЬНЫЙ)
   ========================================================= */
.logo-container {
  display: inline-block;
  background: transparent;
  box-shadow: none; 
}

.logo {
  max-width: 200px;
  height: auto;
  display: block;
  mix-blend-mode: multiply;
}

.vote-page {
  min-height: 100vh;
  padding: 24px 16px 60px;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 0%, #fdfbf7 0%, #f0ebe1 100%);
}

.vote-page.show-thanks .vote-header {
  display: none;
}

.vote-header { text-align: center; margin-bottom: 24px; display: flex; justify-content: center; }

.step { display: none !important; width: 100%; max-width: 540px; margin: 0 auto; }
.step.active { display: block !important; animation: fadeIn 0.4s ease; }
.step.active.thanks { display: flex !important; } 

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-header { text-align: center; margin-bottom: 24px; }
.step-header h1 { font-size: 26px; line-height: 1.2; margin-bottom: 8px; font-weight: 800; }
.step-header .subtitle { font-size: 14px; color: var(--text-muted); font-weight: 500; }

/* Поиск */
.search-container {
  position: relative;
  margin-bottom: 32px;
  z-index: 100;
}
.search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #a39e95;
  pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 20px 24px 20px 52px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid transparent;
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  transition: all 0.2s;
  font-weight: 600;
}
#search-input::placeholder { color: #b0a99f; font-weight: 500; }
#search-input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 8px 30px rgba(194, 139, 56, 0.2);
  transform: translateY(-2px);
}
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.15);
  max-height: 300px;
  overflow-y: auto;
  list-style: none;
  display: none;
  border: 1px solid var(--border);
}
.search-results.active { display: block; animation: slideDown 0.2s ease; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.search-results li {
  padding: 16px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px solid #f5f2ed;
  transition: background 0.1s, color 0.1s;
}
.search-results li:last-child { border-bottom: none; }
.search-results li:hover, .search-results li:active { background: #fdfaf5; color: var(--primary); }
.search-results .no-results { color: var(--text-muted); text-align: center; padding: 24px; font-weight: 500; pointer-events: none; }

/* Выбранные */
.selected-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.selected-header h2 { font-size: 14px; color: var(--text-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.counter-badge {
  background: #e2ded6;
  color: #a39e95;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 100px;
  transition: all 0.3s;
}
.counter-badge.full { background: var(--accent-gold); color: #fff; box-shadow: 0 4px 10px rgba(194, 139, 56, 0.3); }

.selected-list { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.6);
  border-radius: 20px;
  border: 2px dashed #dcd5c8;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-icon { font-size: 32px; opacity: 0.5; }

.selected-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
.selected-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--accent-gold);
}
@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.rank-badge {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  margin-right: 16px;
  flex-shrink: 0;
}
.rank-1 { background: linear-gradient(135deg, #ffd700, #ff8c00); box-shadow: 0 4px 10px rgba(255,215,0,0.4); }
.rank-2 { background: linear-gradient(135deg, #e0e0e0, #9e9e9e); box-shadow: 0 4px 10px rgba(158,158,158,0.4); }
.rank-3 { background: linear-gradient(135deg, #cd7f32, #8b4513); box-shadow: 0 4px 10px rgba(205,127,50,0.4); }

.selected-item .product-name { flex-grow: 1; font-size: 15px; font-weight: 700; line-height: 1.3; }

.remove-btn {
  background: #f5f2ed;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.remove-btn:active { background: #ffe5e5; color: var(--danger); transform: scale(0.9); }

/* Кнопки */
.btn {
  display: block;
  width: 100%;
  padding: 20px;
  border: none;
  border-radius: 16px;
  font-size: 17px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 8px 20px rgba(184, 35, 35, 0.3); }
.btn.primary:active:not(:disabled) { transform: scale(0.98); }
.btn.primary:disabled { background: #e2ded6; color: #a39e95; cursor: not-allowed; box-shadow: none; }

.error { color: var(--danger); font-size: 14px; margin-top: 16px; min-height: 20px; text-align: center; font-weight: 700; }

/* Спасибо */
.thanks {
  text-align: center;
  padding-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.thanks-icon {
  font-size: 80px;
  margin-bottom: 20px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-20px); }
  60% { transform: translateY(-10px); }
}

.thanks h2 { font-size: 28px; margin-bottom: 16px; font-weight: 800; color: var(--text); }
.thanks p { color: var(--text-muted); font-size: 16px; font-weight: 500; max-width: 320px; line-height: 1.6; margin-bottom: 32px; }

.waiting-badge {
  background: linear-gradient(135deg, rgba(194, 139, 56, 0.1), rgba(194, 139, 56, 0.2));
  color: var(--accent-gold-dark);
  font-size: 14px;
  font-weight: 800;
  padding: 12px 24px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid rgba(194, 139, 56, 0.3);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(194, 139, 56, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(194, 139, 56, 0); }
  100% { box-shadow: 0 0 0 0 rgba(194, 139, 56, 0); }
}
/* =========================================================
   ЭКРАН РЕЗУЛЬТАТОВ (ТВ)
   ========================================================= */
.screen-page {
  background-color: #0d1117;
  background-image: radial-gradient(circle at 10% 20%, rgba(184, 35, 35, 0.15) 0%, transparent 40%), radial-gradient(circle at 90% 80%, rgba(245, 196, 81, 0.1) 0%, transparent 40%);
  color: #fff; min-height: 100vh; padding: 40px 60px 60px; font-family: 'Montserrat', sans-serif;
}

.screen-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; flex-wrap: wrap; gap: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 30px; }
.screen-title-group { display: flex; align-items: center; gap: 24px; }

.tv-logo-container {
  background: transparent;
  box-shadow: none;
}

.logo-tv { width: 140px; height: auto; display: block; }

.screen-header h1 { font-size: 42px; font-weight: 800; letter-spacing: -1px; background: linear-gradient(to right, #f5c451, #c28b38); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 0 4px 20px rgba(245, 196, 81, 0.2); }

/* Контейнер */
.chart-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  margin-bottom: 60px; 
  background: rgba(255,255,255,0.02); 
  border: 1px solid rgba(255,255,255,0.06); 
  border-radius: 32px; 
  padding: 40px; 
  box-shadow: 0 20px 40px rgba(0,0,0,0.2); 
  backdrop-filter: blur(10px);
  min-height: 520px; /* Увеличили высоту для большого графика */
}

/* График (занимает больше места) */
.chart-box { 
  flex: 1; /* Занимает все доступное пространство */
  max-width: 600px; /* Но не больше 600px, чтобы не растягивался в овал */
  height: 500px;
  position: relative; 
}

/* Правая панель: статистика + легенда */
.info-panel {
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* Плашка со счетчиком */
.total-votes-badge {
  background: linear-gradient(135deg, rgba(184, 35, 35, 0.1) 0%, rgba(184, 35, 35, 0.02) 100%);
  border: 1px solid rgba(184, 35, 35, 0.3);
  border-radius: 24px;
  padding: 30px;
  text-align: center;
  box-shadow: inset 0 0 20px rgba(184, 35, 35, 0.05);
}

.total-votes-label {
  font-size: 16px;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
  margin-bottom: 8px;
}

.total-votes-number {
  font-size: 64px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.total-votes-number .suffix {
  font-size: 20px;
  font-weight: 600;
  color: #8b949e;
}

/* Кастомная легенда */
.custom-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(255,255,255,0.03);
  border-radius: 24px;
  padding: 24px;
  border: 1px solid rgba(255,255,255,0.06);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 600;
  color: #e6edf3;
  line-height: 1.3;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Таблица */
.table-section h2 { font-size: 28px; margin-bottom: 30px; color: #e6edf3; font-weight: 700; display: flex; align-items: center; gap: 12px; }
.table-section h2::before { content: ''; display: block; width: 6px; height: 28px; background: var(--primary); border-radius: 4px; }
.all-list { list-style: none; display: flex; flex-direction: column; gap: 16px; }
.all-row { padding: 20px 24px; background: rgba(255,255,255,0.03); border-radius: 20px; border: 1px solid rgba(255,255,255,0.05); position: relative; }
.all-row:nth-child(1) { background: linear-gradient(90deg, rgba(245,196,81,0.1) 0%, rgba(255,255,255,0.03) 100%); border-color: rgba(245,196,81,0.3); }
.all-row:nth-child(2) { background: linear-gradient(90deg, rgba(192,192,192,0.1) 0%, rgba(255,255,255,0.03) 100%); border-color: rgba(192,192,192,0.3); }
.all-row:nth-child(3) { background: linear-gradient(90deg, rgba(205,127,50,0.1) 0%, rgba(255,255,255,0.03) 100%); border-color: rgba(205,127,50,0.3); }
.all-row-head { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; font-size: 20px; margin-bottom: 12px; font-weight: 600; }
.place { font-size: 24px; font-weight: 800; color: #8b949e; }
.all-row:nth-child(1) .place { color: #f5c451; }
.all-row:nth-child(2) .place { color: #c0c0c0; }
.all-row:nth-child(3) .place { color: #cd7f32; }
.pname { color: #e6edf3; }
.pval { color: #f5c451; font-weight: 800; font-size: 28px; background: rgba(245,196,81,0.1); padding: 4px 16px; border-radius: 100px; }
.all-row:nth-child(2) .pval { color: #c0c0c0; background: rgba(192,192,192,0.1); }
.all-row:nth-child(3) .pval { color: #cd7f32; background: rgba(205,127,50,0.1); }
.bar-track { height: 12px; background: rgba(255,255,255,0.06); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #c28b38, #f5c451); border-radius: 8px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }
.all-row:nth-child(1) .bar-fill { background: linear-gradient(90deg, #ffb300, #ffd700); box-shadow: 0 0 10px rgba(255,215,0,0.5); }
.all-row:nth-child(2) .bar-fill { background: linear-gradient(90deg, #9e9e9e, #e0e0e0); }
.all-row:nth-child(3) .bar-fill { background: linear-gradient(90deg, #a0522d, #cd7f32); }
.all-row-sub { font-size: 14px; color: #8b949e; font-weight: 500; display: flex; gap: 16px; }

/* Адаптив для маленьких экранов */
@media (max-width: 1200px) {
  .chart-container { flex-direction: column; padding: 20px; gap: 20px; min-height: auto; }
  .chart-box { width: 100%; max-width: 400px; height: 350px; }
  .info-panel { width: 100%; max-width: 400px; }
  .total-votes-number { font-size: 48px; }
  .screen-header h1 { font-size: 32px; }
  .all-row-head { font-size: 18px; }
  .pval { font-size: 22px; }
  .screen-title-group { flex-direction: column; align-items: flex-start; gap: 12px; }
}