/* ═══ ПЕРЕМЕННЫЕ ═══════════════════════════════════════════════════════════ */
:root {
  --bg:         #0d0d1f;
  --bg2:        #13132a;
  --card-bg:    rgba(255,255,255,0.05);
  --card-hover: rgba(255,255,255,0.08);
  --border:     rgba(255,255,255,0.08);
  --gold:       #FFD700;
  --silver:     #C0C0C0;
  --bronze:     #CD7F32;
  --accent:     #6C63FF;
  --green:      #00E676;
  --text:       #FFFFFF;
  --text-dim:   rgba(255,255,255,0.55);
  --font:       'Segoe UI', system-ui, sans-serif;
}

/* ═══ СБРОС И БАЗА ══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
}

/* ═══ ОСНОВНОЙ ЭКРАН ════════════════════════════════════════════════════════ */
#main-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 16px 24px;
  gap: 12px;
}

/* ───── Шапка ─────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold), #FF8C00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#clock {
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ═══ ПАНЕЛИ ════════════════════════════════════════════════════════════════ */
.panels {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}

.panel-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  min-height: 0;
  overflow: hidden;
}

.panel-today { /* занимает всю высоту левой колонки */ }
.panel-week  { flex: 1; }
.panel-month { flex: 1; }

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

.panel-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.panel-total {
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
  color: var(--green);
}

.panel-today .panel-title  { color: var(--gold); }
.panel-today .panel-header { border-color: rgba(255,215,0,0.25); }
.panel-today .panel-total  { color: var(--gold); }

.panel-week  .panel-title  { color: #7EC8E3; }
.panel-week  .panel-total  { color: #7EC8E3; }

.panel-month .panel-title  { color: #B39DDB; }
.panel-month .panel-total  { color: #B39DDB; }

.panel-list {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 16px;
}

/* ───── Строка сотрудника ──────────────────────────────────────────────────── */
.panel-row {
  display: grid;
  grid-template-columns: 28px 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.2s;
  animation: rowIn 0.3s ease;
  flex-shrink: 0;
}

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.panel-row:nth-child(1) { border-color: rgba(255,215,0,0.3); background: rgba(255,215,0,0.04); }
.panel-row:nth-child(2) { border-color: rgba(192,192,192,0.2); }
.panel-row:nth-child(3) { border-color: rgba(205,127,50,0.2); }

.row-rank {
  font-size: 1.1rem;
  text-align: center;
  line-height: 1;
}

.rank-num {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
}

.row-photo {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.row-photo-ph {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

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

.row-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-row:nth-child(1) .row-name { font-size: 1rem; }

.row-team {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-right {
  text-align: right;
  flex-shrink: 0;
}

.row-amount {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--green);
  white-space: nowrap;
}

.panel-row:nth-child(1) .row-amount { color: var(--gold); font-size: 1.05rem; }

.row-deals {
  font-size: 0.7rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ═══ СТАТУС WS ════════════════════════════════════════════════════════════ */
#ws-status {
  position: fixed;
  bottom: 10px; right: 14px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #f44336;
  transition: background 0.5s;
}
#ws-status.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }

/* ═══ ЭКРАН ПРОДАЖИ ════════════════════════════════════════════════════════ */
#sale-screen {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #1a0a3e 0%, #0a0a1f 60%, #000 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: saleIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#sale-screen.hidden { display: none; }

@keyframes saleIn {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.sale-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 1;
  text-align: center;
  padding: 40px;
}

.sale-badge {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.4em;
  color: var(--gold);
  text-transform: uppercase;
  padding: 8px 28px;
  border: 2px solid var(--gold);
  border-radius: 30px;
  animation: badgePulse 1s ease infinite alternate;
}

@keyframes badgePulse {
  from { box-shadow: 0 0 10px rgba(255,215,0,0.3); }
  to   { box-shadow: 0 0 30px rgba(255,215,0,0.8), 0 0 60px rgba(255,215,0,0.3); }
}

.sale-photo-wrap { position: relative; }

#sale-photo {
  width: 220px; height: 220px;
  border-radius: 50%;
  object-fit: cover;
  border: 5px solid var(--gold);
  box-shadow: 0 0 40px rgba(255,215,0,0.5), 0 0 80px rgba(255,215,0,0.2);
  animation: photoPulse 1.5s ease infinite alternate;
}

@keyframes photoPulse {
  from { box-shadow: 0 0 30px rgba(255,215,0,0.4); }
  to   { box-shadow: 0 0 60px rgba(255,215,0,0.9), 0 0 100px rgba(108,99,255,0.3); }
}

.sale-photo-placeholder {
  width: 220px; height: 220px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4A00E0);
  display: flex; align-items: center; justify-content: center;
  font-size: 5rem; font-weight: 700;
  border: 5px solid var(--gold);
  box-shadow: 0 0 40px rgba(255,215,0,0.5);
}

#sale-name {
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(135deg, #fff, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

#sale-team {
  font-size: 1rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#sale-amount {
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255,215,0,0.6);
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
}

/* ═══ КОНФЕТТИ ══════════════════════════════════════════════════════════════ */
#confetti-container {
  position: fixed; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.confetti {
  position: absolute;
  top: -20px;
  opacity: 0;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg) scale(0.5); opacity: 0; }
}

/* ═══ ЗНАЧОК МУЗЫКИ ═════════════════════════════════════════════════════════ */
#music-badge {
  position: fixed;
  bottom: 28px; left: 16px;
  background: rgba(108,99,255,0.85);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#music-badge.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ═══ АКТИВАЦИЯ ЗВУКА ═══════════════════════════════════════════════════════ */
#sound-unlock {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75);
  cursor: pointer;
  transition: opacity 0.4s;
}
.sound-unlock-box {
  text-align: center;
  padding: 40px 56px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  animation: pulseUnlock 2s ease infinite;
}
@keyframes pulseUnlock {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 rgba(108,99,255,0); }
  50%       { transform: scale(1.03); box-shadow: 0 0 40px rgba(108,99,255,0.4); }
}
.sound-unlock-icon { font-size: 3.5rem; margin-bottom: 16px; }
.sound-unlock-text { font-size: 1.3rem; font-weight: 700; color: #fff; margin-bottom: 6px; }
.sound-unlock-sub  { font-size: 0.9rem; color: rgba(255,255,255,0.5); }

.hidden { display: none !important; }
