/* TrackVato — self-contained stylesheet */

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

:root {
  --bg:        #0d0d0d;
  --surface:   #111417;
  --hover:     #161b20;
  --border:    rgba(255,255,255,0.07);
  --accent:    #f5a623;
  --text:      #e0e0e0;
  --muted:     #666;
  --dim:       #333;
  --mono:      'JetBrains Mono', 'Courier New', monospace;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }

/* ──────────────────────────────────────────
   PAGE SHELL
────────────────────────────────────────── */
.tv-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* ──────────────────────────────────────────
   HEADER
────────────────────────────────────────── */
.tv-header {
  padding: 44px 0 28px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.tv-logo {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -2px;
  color: var(--text);
  line-height: 1;
}
.tv-logo span { color: var(--accent); }

.tv-tagline {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}

/* Live badge */
.tv-live-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  border: 1px solid rgba(245,166,35,0.3);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 2px;
}
.tv-live-dot span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 2s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }

/* Market nav */
.tv-nav {
  display: inline-flex;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.tv-nav-item {
  padding: 7px 22px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted) !important;
  transition: background .15s, color .15s;
  border-right: 1px solid var(--border);
}
.tv-nav-item:last-child { border-right: none; }
.tv-nav-item:hover      { background: var(--hover); color: var(--text) !important; }
.tv-nav-item.active     { background: var(--accent); color: var(--bg) !important; }

.tv-week-range {
  margin-top: 10px;
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 1px;
}

/* ──────────────────────────────────────────
   TABLE WRAPPER
────────────────────────────────────────── */
.tv-main {
  margin-top: 0;
  width: 100%;
}

/* ──────────────────────────────────────────
   COLUMN SIZES  (single source of truth)
   left-panel  = rank + thumb + name
   right-panel = sales
   middle      = 7 day columns (flex:1)
────────────────────────────────────────── */
.tv-left  { width: 260px; flex-shrink: 0; }
.tv-mid   { flex: 1; min-width: 0; }
.tv-right { width: 100px; flex-shrink: 0; }

/* ──────────────────────────────────────────
   META BAR
────────────────────────────────────────── */
.tv-meta-bar {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid var(--border);
}
.tv-meta-bar strong { color: var(--muted); }

/* ──────────────────────────────────────────
   DAY HEADER BAR
────────────────────────────────────────── */
.tv-day-bar {
  display: flex;
  align-items: stretch;
  height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
}
.tv-day-bar.sticky {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  border-top: 2px solid var(--accent);
  box-shadow: 0 4px 20px rgba(0,0,0,.8);
}

/* spacer that matches .tv-left width */
.tv-day-spacer {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.tv-days {
  flex: 1;
  display: flex;
  list-style: none;
}

.tv-day {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: background .12s, color .12s;
  user-select: none;
}
.tv-day:last-child  { border-right: none; }
.tv-day:hover:not(.future) { background: rgba(245,166,35,.08); color: var(--accent); }
.tv-day.active      { background: rgba(245,166,35,.12); color: var(--accent); font-weight: 700; }
.tv-day.future      { cursor: default; color: var(--muted); opacity: 0.5; }

/* spacer that matches .tv-right width */
.tv-day-right-spacer {
  width: 100px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
}

.tv-day-x { display: none; font-size: 11px; }
.tv-day.active .tv-day-x { display: inline; }

/* ──────────────────────────────────────────
   ITEM ROW
────────────────────────────────────────── */
.tv-item {
  display: flex;
  align-items: stretch;
  height: 80px;
  max-height: 80px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: var(--surface);
  transition: background .1s;
  animation: row-in .25s ease both;
  overflow: hidden;
}
.tv-item:nth-child(even) { background: #0f1215; }
.tv-item:hover            { background: var(--hover) !important; }

@keyframes row-in { from{opacity:0;transform:translateX(-4px)} to{opacity:1;transform:none} }
.tv-item:nth-child(1) {animation-delay:.03s}
.tv-item:nth-child(2) {animation-delay:.06s}
.tv-item:nth-child(3) {animation-delay:.09s}
.tv-item:nth-child(4) {animation-delay:.12s}
.tv-item:nth-child(5) {animation-delay:.15s}
.tv-item:nth-child(6) {animation-delay:.18s}
.tv-item:nth-child(7) {animation-delay:.21s}
.tv-item:nth-child(8) {animation-delay:.24s}
.tv-item:nth-child(9) {animation-delay:.27s}
.tv-item:nth-child(10){animation-delay:.30s}

/* LEFT PANEL — rank + thumb + name */
.tv-left {
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border);
  overflow: hidden;
  height: 80px;
  max-height: 80px;
}

.tv-rank {
  width: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--dim);
  align-self: stretch;
  border-right: 1px solid var(--border);
}
.tv-item[data-rank="1"] .tv-rank { color: var(--accent); }
.tv-item[data-rank="2"] .tv-rank { color: #888; }
.tv-item[data-rank="3"] .tv-rank { color: #7a5230; }

.tv-thumb {
  width: 68px !important;
  height: 68px !important;
  min-width: 68px !important;
  max-width: 68px !important;
  min-height: 68px !important;
  max-height: 68px !important;
  flex-shrink: 0;
  display: block;
  overflow: hidden;
  margin: 6px 4px;
  border-radius: 4px;
}
.tv-thumb img {
  width: 68px !important;
  height: 68px !important;
  max-width: 68px !important;
  max-height: 68px !important;
  object-fit: cover;
  object-position: center;
  display: block;
  opacity: .9;
  transition: opacity .2s;
}
.tv-item:hover .tv-thumb img { opacity: 1; }

.tv-name {
  flex: 1;
  min-width: 0;
  padding: 0 10px 0 6px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* MIDDLE PANEL — charts + day numbers */
.tv-mid {
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

/* Day number row */
.tv-week-numbers {
  display: flex;
  list-style: none;
  height: 26px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.tv-week-numbers li {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  border-right: 1px solid var(--border);
}
.tv-week-numbers li:last-child { border-right: none; }

/* Charts */
.tv-chart-weekly,
.tv-chart-hourly {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.tv-chart-hourly { display: none; }

.tv-chart-weekly canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* Hourly bars */
.tv-hourly-bars {
  display: none;
  position: absolute;
  inset: 2px 0 0;
  align-items: flex-end;
}
.tv-bar {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  padding: 0 1px;
}
.tv-bar span {
  display: block;
  width: 100%;
  min-height: 2px;
  background: rgba(245,166,35,.22);
  border-top: 1px solid rgba(245,166,35,.5);
}
.tv-item:hover .tv-bar span { background: rgba(245,166,35,.38); }

/* RIGHT PANEL — sales */
.tv-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 8px;
  background: rgba(0,0,0,.2);
}
.tv-sales-num {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1;
}
.tv-item[data-rank="1"] .tv-sales-num { color: var(--accent); }
.tv-sales-label {
  font-size: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}

/* ──────────────────────────────────────────
   FOOTER
────────────────────────────────────────── */
.tv-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--dim);
}
.tv-footer a { color: var(--dim); border-bottom: 1px solid var(--border); }
.tv-footer a:hover { color: var(--muted); }

/* ──────────────────────────────────────────
   TOAST
────────────────────────────────────────── */
.tv-toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid rgba(245,166,35,.3);
  color: var(--text);
  font-size: 11px;
  letter-spacing: 1px;
  padding: 10px 24px;
  border-radius: 3px;
  white-space: nowrap;
  transition: bottom .35s ease;
  z-index: 100;
}
.tv-toast.show { bottom: 24px; }

/* ──────────────────────────────────────────
   BACK TO TOP
────────────────────────────────────────── */
.tv-top {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 36px; height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, background .15s;
  z-index: 99;
}
.tv-top.show          { opacity: 1; pointer-events: all; }
.tv-top:hover         { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* ──────────────────────────────────────────
   RESPONSIVE
────────────────────────────────────────── */
@media (max-width: 900px) {
  .tv-left  { width: 200px; }
  .tv-day-spacer { width: 200px; }
  .tv-right { width: 80px; }
  .tv-day-right-spacer { width: 80px; }
  .tv-rank  { width: 30px; }
  .tv-thumb { width: 58px; height: 58px; }
  .tv-sales-num { font-size: 14px; }
  .tv-name  { font-size: 10px; }
}

@media (max-width: 640px) {
  .tv-page  { padding: 0 10px 40px; }
  .tv-logo  { font-size: 32px; }
  .tv-left  { width: 160px; }
  .tv-day-spacer { width: 160px; }
  .tv-right { width: 64px; }
  .tv-day-right-spacer { width: 64px; }
  .tv-rank  { width: 24px; font-size: 11px; }
  .tv-thumb { width: 48px; height: 48px; margin: 4px 2px; }
  .tv-name  { font-size: 9px; padding: 0 4px; -webkit-line-clamp: 2; }
  .tv-sales-num { font-size: 12px; }
  .tv-sales-label { display: none; }
  .tv-day   { font-size: 8px; letter-spacing: 1px; }
  .tv-week-numbers li { font-size: 9px; }
  .tv-header { padding: 24px 0 18px; }
  .tv-meta-bar { flex-direction: column; gap: 2px; }
}
