* { box-sizing: border-box; }
:root {
  --navy: #06162f;
  --navy-2: #102a5a;
  --blue: #3f90ff;
  --blue-2: #6db5ff;
  --orange: #ff8a1f;
  --orange-2: #ffb45e;
  --bg: radial-gradient(circle at top, #17386f 0%, #0a1630 28%, #07111f 100%);
  --card: rgba(255,255,255,0.08);
  --card-soft: rgba(255,255,255,0.06);
  --text: #ffffff;
  --muted: #b5c6e6;
  --line: rgba(255,255,255,0.12);
  --success: #46df91;
  --danger: #ff6b6b;
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
strong { font-weight: 800; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  background: linear-gradient(180deg, rgba(7,20,43,.92), rgba(8,18,35,.96));
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 14px; background: linear-gradient(135deg, var(--orange), var(--orange-2));
  font-weight: 800; font-size: 24px;
  box-shadow: 0 10px 25px rgba(255,138,31,.35);
}
.brand strong { display: block; font-size: 18px; letter-spacing: .04em; }
.brand span { display: block; font-size: 11px; opacity: .75; letter-spacing: .16em; }
nav { display: grid; gap: 8px; }
.nav-item {
  border: 0; border-radius: 14px; padding: 13px 14px;
  background: transparent; color: #dbe6fb; text-align: left; font-weight: 600;
}
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.11); color: #fff; }
.sidebar-footer { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-footer span { display: block; font-weight: 700; }
.sidebar-footer small { opacity: .75; }

.main { padding: 26px; overflow: hidden; }
.topbar {
  display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 18px;
}
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .14em; color: #9bc5ff; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 30px; }

.period-switch {
  display: inline-flex; background: rgba(255,255,255,.08); padding: 4px; border-radius: 14px; border: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.period-switch button { border: 0; background: transparent; padding: 9px 14px; border-radius: 10px; color: var(--muted); font-weight: 700; }
.period-switch button.active { background: linear-gradient(135deg, var(--blue), #295ed3); color: #fff; }
.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.08);
  color: #fff;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 12px;
  backdrop-filter: blur(14px);
}
.ghost-btn:hover { border-color: rgba(255,255,255,.25); }

.view { display: none; }
.view.active { display: block; }

.hero {
  background:
    radial-gradient(circle at 85% 10%, rgba(255,179,94,.28), transparent 28%),
    radial-gradient(circle at 18% 22%, rgba(63,144,255,.25), transparent 32%),
    linear-gradient(135deg, rgba(9,25,54,.95), rgba(16,42,90,.92));
  color: #fff; padding: 24px 28px; border-radius: 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 30px;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 18px 45px rgba(0,0,0,.22);
}
.hero h2 { font-size: 32px; margin-bottom: 8px; max-width: 620px; }
.hero p { color: #cbd8ef; margin-bottom: 0; }
.badge {
  display: inline-block; background: rgba(255,138,31,.15); color: #ffd8b2;
  border: 1px solid rgba(255,138,31,.35); padding: 8px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 800; margin-bottom: 14px;
}
.hero-score {
  min-width: 220px; padding: 22px; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12); border-radius: 18px; backdrop-filter: blur(14px);
}
.hero-score small, .hero-score span { display: block; color: #d9e3f6; }
.hero-score strong { display: block; font-size: 27px; margin: 6px 0; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0; }
.metric-card, .panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  backdrop-filter: blur(18px);
}
.metric-card { padding: 18px 18px 16px; }
.metric-card span { display: block; color: #c4d4ef; font-size: 13px; font-weight: 700; }
.metric-card strong { display: block; font-size: 28px; margin: 8px 0 5px; }
.metric-card small { color: #9eb2d1; }

.panel { padding: 18px; margin-top: 14px; }
.panel-head { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 16px; }
.panel-head h3 { margin-bottom: 0; font-size: 20px; }
.live-dot { color: var(--success); font-size: 12px; font-weight: 700; }

.progress { height: 16px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--orange), var(--orange-2));
  border-radius: inherit; transition: width .5s ease;
  box-shadow: 0 0 18px rgba(255,138,31,.55);
}
.progress-caption { display: flex; justify-content: space-between; color: var(--muted); margin-top: 10px; font-size: 13px; }

.tv-grid {
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  gap: 14px;
  align-items: stretch;
}
.podium-panel {
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.08), transparent 32%),
    linear-gradient(180deg, rgba(7,18,35,.92), rgba(10,17,31,.96));
  overflow: hidden;
  min-height: 620px;
}
.podium-board {
  position: relative;
  min-height: 540px;
  padding: 10px 10px 0;
  overflow: hidden;
}
.podium-board::before, .podium-board::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  inset: auto;
  pointer-events: none;
}
.podium-board::before {
  width: 760px; height: 760px;
  left: 50%; top: -520px; transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow:
    0 0 0 60px rgba(255,255,255,.04),
    0 0 0 120px rgba(255,255,255,.025),
    0 0 0 180px rgba(255,255,255,.02);
  animation: spinSlow 24s linear infinite;
}
.podium-board::after {
  width: 420px; height: 420px;
  left: 50%; top: -240px; transform: translateX(-50%);
  border: 1px solid rgba(255,179,94,.18);
  box-shadow:
    0 0 0 50px rgba(255,179,94,.06),
    0 0 0 100px rgba(63,144,255,.035);
  animation: pulseRing 8s ease-in-out infinite;
}
.podium-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1.18fr 1fr;
  align-items: end;
  gap: 12px;
  min-height: 520px;
}
.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
}
.podium-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
  animation: floatY 4s ease-in-out infinite;
}
.podium-slot.first .podium-avatar-wrap { animation-duration: 3.4s; }
.podium-slot.third .podium-avatar-wrap { animation-duration: 4.6s; }
.podium-avatar {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 50%;
  background: #fff;
  border: 4px solid #fff;
  box-shadow: 0 16px 40px rgba(0,0,0,.32), 0 0 0 8px rgba(255,255,255,.05);
}
.podium-slot.first .podium-avatar {
  width: 116px;
  height: 116px;
  border-color: #ffd27b;
  box-shadow: 0 18px 40px rgba(0,0,0,.38), 0 0 32px rgba(255,191,92,.28);
}
.podium-rank-badge {
  margin-top: -12px;
  background: var(--orange);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 6px 9px;
  border: 2px solid #0d1728;
  box-shadow: 0 8px 20px rgba(255,138,31,.36);
}
.podium-slot.first .podium-rank-badge { background: #f7b23c; }
.podium-name {
  font-weight: 800;
  margin-top: 10px;
  font-size: 18px;
}
.podium-sales {
  color: #b8c7e6;
  font-size: 13px;
  margin-top: 4px;
  font-weight: 700;
}
.podium-status {
  margin-top: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  max-width: 190px;
  line-height: 1.35;
}
.podium-quote {
  margin-top: 6px;
  color: #c8d5ed;
  font-size: 11px;
  line-height: 1.35;
  max-width: 190px;
}
.pedestal {
  width: 100%;
  max-width: 182px;
  background: linear-gradient(180deg, #ffffff, #eceef5);
  border-radius: 24px 24px 16px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8d95a6;
  font-size: 42px;
  font-weight: 900;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.65), 0 10px 28px rgba(0,0,0,.16);
  position: relative;
  animation: pedestalBounce 3.8s ease-in-out infinite;
}
.pedestal::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  width: 112%;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.96), rgba(240,244,250,.96));
  box-shadow: 0 7px 20px rgba(0,0,0,.12);
}
.podium-slot.second .pedestal { height: 182px; animation-delay: .3s; }
.podium-slot.first .pedestal { height: 252px; color: #70607f; animation-delay: 0s; }
.podium-slot.third .pedestal { height: 160px; color: #d08b2f; animation-delay: .6s; }

.ranking-panel { min-height: 620px; }
.ranking-list { display: grid; gap: 10px; }
.rank-row {
  display: grid;
  grid-template-columns: 54px 56px 1.3fr .52fr .62fr 1.18fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
}
.rank-row.top-1 {
  background: linear-gradient(90deg, rgba(255,190,90,.14), rgba(255,255,255,.045));
  border-color: rgba(255,210,123,.28);
}
.rank-pos {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 800; background: rgba(255,255,255,.09);
}
.rank-avatar {
  width: 46px; height: 46px; object-fit: cover; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.65);
}
.rank-name { font-weight: 800; font-size: 15px; }
.rank-status { color: #fff; font-weight: 800; font-size: 12px; margin-top: 4px; }
.rank-quote { color: var(--muted); font-size: 11px; margin-top: 5px; line-height: 1.36; }
.stat-label { display: block; color: #aac0e2; font-size: 10px; font-weight: 700; margin-bottom: 4px; letter-spacing: .04em; }
.stat-value { font-weight: 800; font-size: 18px; }
.individual-progress { display: flex; align-items: center; gap: 10px; }
.individual-progress .mini-bar {
  flex: 1; height: 10px; border-radius: 999px; background: rgba(255,255,255,.09); overflow: hidden;
}
.individual-progress .mini-bar span {
  display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-2));
  box-shadow: 0 0 12px rgba(63,144,255,.45);
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.simple-form { grid-template-columns: repeat(3, minmax(0,1fr)); }
label { display: grid; gap: 8px; font-weight: 700; font-size: 13px; color: #dce7fb; }
input, select {
  width: 100%; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 13px 14px;
  background: rgba(255,255,255,.06); outline: none; color: #fff;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,103,217,.18); }
select option { color: #111; }
.primary-btn {
  margin-top: 18px; border: 0; background: linear-gradient(135deg, var(--orange), var(--orange-2)); color: #fff; font-weight: 800;
  padding: 13px 18px; border-radius: 12px; box-shadow: 0 12px 24px rgba(255,138,31,.24);
}
.form-message { margin-top: 14px; font-weight: 700; color: #8df1b8; min-height: 20px; }

.history-panel { margin-top: 14px; }
.entry-history {
  display: grid;
  gap: 10px;
}
.history-empty {
  padding: 18px;
  border: 1px dashed rgba(255,255,255,.14);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}
.history-item {
  display: grid;
  grid-template-columns: 48px 1.3fr .7fr .85fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
}
.history-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.65);
}
.history-name { font-weight: 800; }
.history-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.delete-btn {
  border: 1px solid rgba(255,107,107,.32);
  background: rgba(255,107,107,.12);
  color: #ffd1d1;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 800;
}
.delete-btn:hover {
  background: rgba(255,107,107,.18);
}

.status-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.legend-item {
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255,255,255,.03);
}
.legend-range {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: #9bc5ff;
  margin-bottom: 4px;
}
.legend-title {
  font-weight: 800;
  font-size: 14px;
  color: #fff;
}

.team-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.team-card {
  border: 1px solid rgba(255,255,255,.10); border-radius: 18px; padding: 18px;
  background: rgba(255,255,255,.035);
}
.team-card h4 { margin: 0 0 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.team-avatar {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,255,255,.65);
}
.team-card p { margin: 0; color: var(--muted); font-size: 13px; }
.team-status {
  margin: 8px 0 8px;
  font-weight: 800;
  color: #fff;
  font-size: 14px;
}
.team-footer { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 12px; }
.team-points { font-size: 13px; color: var(--muted); font-weight: 700; }

/* TV mode */
body.tv-mode .app-shell { grid-template-columns: 1fr; }
body.tv-mode .sidebar,
body.tv-mode .view:not(#dashboard),
body.tv-mode .toolbar #resetDataBtn {
  display: none !important;
}
body.tv-mode .main { padding: 18px; }
body.tv-mode .topbar { margin-bottom: 14px; }
body.tv-mode .hero { padding: 18px 22px; }
body.tv-mode .hero h2 { font-size: 28px; }
body.tv-mode .metrics { gap: 10px; }
body.tv-mode .metric-card { padding: 16px; }
body.tv-mode .metric-card strong { font-size: 30px; }
body.tv-mode .tv-grid { grid-template-columns: 1.12fr 0.88fr; }
body.tv-mode .podium-panel, body.tv-mode .ranking-panel { min-height: 0; }
body.tv-mode .podium-board { min-height: 500px; }
body.tv-mode .rank-row { padding: 14px 12px; }

/* Animations */
@keyframes floatY {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}
@keyframes pedestalBounce {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
}
@keyframes spinSlow {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg); }
}
@keyframes pulseRing {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: .9; }
  50% { transform: translateX(-50%) scale(1.04); opacity: 1; }
}

@media (max-width: 1280px) {
  .tv-grid { grid-template-columns: 1fr; }
  .podium-panel, .ranking-panel { min-height: auto; }
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; flex-direction: row; align-items: center; gap: 16px; }
  .sidebar nav { display: flex; margin-left: auto; }
  .sidebar-footer { display: none; }
  .brand { padding: 0; }
  .nav-item span { display: none; }
  .metrics, .status-legend, .team-grid { grid-template-columns: 1fr; }
  .podium-layout { grid-template-columns: 1fr; gap: 18px; min-height: auto; }
  .podium-board { min-height: auto; }
  .simple-form { grid-template-columns: 1fr; }
  .history-item { grid-template-columns: 44px 1fr; }
  .history-item > div:nth-child(3),
  .history-item > div:nth-child(4),
  .history-item > button { grid-column: 2; }
  .rank-row { grid-template-columns: 42px 42px 1fr; }
  .rank-row > div:nth-child(4),
  .rank-row > div:nth-child(5),
  .rank-row > div:nth-child(6) { grid-column: 3; }
}
@media (max-width: 680px) {
  .main { padding: 18px; }
  .topbar, .hero { align-items: flex-start; flex-direction: column; }
  .toolbar { flex-direction: column; align-items: stretch; width: 100%; }
  .hero h2 { font-size: 24px; }
  .hero-score { width: 100%; }
  .metrics, .form-grid { grid-template-columns: 1fr; }
}
