:root {
  --brand: #7050a8;
  --brand-dark: #4b326f;
  --brand-soft: #f2eef7;
  --brand-faint: #faf9fc;
  --ink: #241f2b;
  --muted: #786f83;
  --line: #e7e1ec;
  --white: #ffffff;
  --success: #168866;
  --success-soft: #eaf8f3;
  --danger: #d64b67;
  --danger-soft: #fff0f3;
  --gold: #c78a22;
  --shadow: 0 16px 44px rgba(54, 38, 69, 0.08);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  direction: rtl;
  color: var(--ink);
  background: #fff;
  font-family: "Heebo", Arial, sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 5%, rgba(112, 80, 168, .07), transparent 24%),
    linear-gradient(180deg, #fff 0%, #fdfbff 100%);
}
.ambient { display: none; }

.dashboard {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: clamp(11px, 1.2vh, 18px);
  padding: clamp(16px, 1.35vw, 27px) clamp(20px, 1.8vw, 36px) clamp(13px, 1.1vw, 22px);
}

.topbar {
  min-height: 60px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.brand {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 13px;
}
.brand-mark {
  width: clamp(48px, 3.3vw, 64px);
  height: clamp(48px, 3.3vw, 64px);
  object-fit: cover;
  border-radius: 9px;
  box-shadow: 0 7px 22px rgba(75, 50, 111, .12);
}
.brand-copy h1 {
  margin: 0;
  color: var(--brand);
  font-size: clamp(22px, 1.55vw, 30px);
  font-weight: 900;
  line-height: 1;
}
.brand-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: clamp(11px, .72vw, 14px);
}
.center-status {
  direction: ltr;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border: 1px solid #e2d9ec;
  border-radius: 999px;
  font-size: clamp(10px, .68vw, 13px);
}
.center-status strong { color: var(--brand); letter-spacing: .1em; }
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(112, 80, 168, .1);
  animation: pulse 1.8s infinite;
}
.clock-wrap { justify-self: end; direction: ltr; text-align: right; }
#clock { color: var(--ink); font-size: clamp(23px, 1.8vw, 34px); font-weight: 900; line-height: 1; }
#date-label { margin-top: 5px; color: var(--muted); direction: rtl; font-size: clamp(10px, .72vw, 14px); }

.score-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(10px, 1vw, 17px);
}
.score-card {
  position: relative;
  min-width: 0;
  min-height: clamp(76px, 9.1vh, 105px);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(10px, .85vw, 16px);
  padding: clamp(12px, 1vw, 18px);
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(65, 34, 88, .055);
}
.score-card.primary {
  color: white;
  background: linear-gradient(135deg, var(--brand-dark), #7f60b1);
  border-color: transparent;
  box-shadow: 0 14px 34px rgba(75, 50, 111, .2);
}
.score-card.primary span, .score-card.primary small { color: rgba(255,255,255,.8); }
.score-icon {
  width: clamp(40px, 3vw, 54px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 14px;
  font-size: clamp(18px, 1.3vw, 25px);
  font-weight: 900;
}
.primary .score-icon { color: var(--brand); background: white; }
.score-icon.mint { color: var(--success); background: var(--success-soft); }
.score-icon.purple { color: var(--brand); background: var(--brand-soft); }
.score-icon.amber { color: var(--gold); background: #fff7e8; }
.score-card span { display: block; color: var(--muted); white-space: nowrap; font-size: clamp(11px, .76vw, 15px); }
.score-card strong { display: block; margin-top: 2px; white-space: nowrap; font-size: clamp(21px, 1.78vw, 34px); line-height: 1.06; }
.score-card small { align-self: end; padding-bottom: 3px; color: var(--brand); white-space: nowrap; font-size: clamp(9px, .66vw, 13px); font-weight: 700; }

.main-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(340px, .78fr);
  gap: clamp(12px, 1.15vw, 20px);
}
.panel {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow: var(--shadow);
}
.leaderboard-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(14px, 1.15vw, 22px);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: clamp(10px, 1vh, 14px);
}
.eyebrow {
  display: block;
  color: var(--brand);
  direction: ltr;
  font-size: clamp(9px, .61vw, 12px);
  font-weight: 900;
  letter-spacing: .12em;
}
.panel h2 { margin: 1px 0 0; font-size: clamp(18px, 1.42vw, 27px); }
.leaderboard-title p { margin: 2px 0 0; color: var(--muted); font-size: clamp(9px, .62vw, 12px); }
.metric-switch { min-width: min(49%, 490px); }
.metric-switch > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  text-align: center;
  font-size: clamp(9px, .6vw, 11px);
  font-weight: 700;
}
.metric-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 5px;
  background: var(--brand-soft);
  border: 1px solid #e1d8ea;
  border-radius: 15px;
}
.metric-tabs button {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  color: #7e6f88;
  background: transparent;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
.metric-tabs button i { font-style: normal; font-size: clamp(15px, 1vw, 19px); }
.metric-tabs button b { font-size: clamp(10px, .7vw, 13px); }
.metric-tabs button.active {
  color: white;
  background: var(--brand);
  box-shadow: 0 8px 18px rgba(75, 50, 111, .2);
}
.leaderboard-head, .leader-row {
  display: grid;
  grid-template-columns: .55fr 2.05fr .75fr .95fr 1.14fr .34fr;
  align-items: center;
  column-gap: 10px;
}
.leaderboard-head {
  padding: 0 12px 7px;
  color: #978ba0;
  font-size: clamp(9px, .62vw, 12px);
  font-weight: 700;
}
#metric-column-title { color: var(--brand); font-weight: 900; }
.leaderboard {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-auto-rows: minmax(0, 1fr);
  gap: clamp(4px, .43vh, 7px);
}
.leader-row {
  min-height: 0;
  padding: clamp(2px, .45vh, 5px) 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #eee6f3;
  border-radius: 12px;
  transition: background .35s ease, border-color .35s ease, transform .35s ease;
  animation: rowIn .42s both;
}
.leader-row:nth-child(even) { background: #fdfaff; }
.leader-row.top {
  color: white;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(75, 50, 111, .18);
}
.rank {
  width: clamp(27px, 2vw, 37px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-radius: 10px;
  font-size: clamp(12px, .84vw, 16px);
  font-weight: 900;
}
.top .rank { color: var(--brand-dark); background: white; }
.rep-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rep-copy {
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  overflow: hidden;
}
.avatar {
  width: clamp(30px, 2.15vw, 41px);
  aspect-ratio: 1;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-radius: 11px;
  font-size: clamp(10px, .76vw, 14px);
  font-weight: 900;
}
.top .avatar { color: var(--brand-dark); background: rgba(255,255,255,.92); }
.rep-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(12px, .88vw, 17px);
  line-height: 1.05;
}
.rep-cell small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(8px, .56vw, 11px);
  line-height: 1.05;
}
.top .rep-cell small, .top .table-value, .top .performance small { color: rgba(255,255,255,.76); }
.table-value { color: #4f4756; font-size: clamp(11px, .8vw, 16px); }
.table-value.muted { color: #7d7288; }
.top .table-value.muted { color: rgba(255,255,255,.84); }
.performance strong { display: block; color: var(--ink); font-size: clamp(13px, .98vw, 19px); }
.performance small { color: var(--muted); font-size: clamp(8px, .56vw, 11px); }
.performance.up strong { color: var(--success); }
.top .performance strong { color: white; }
.trend { color: var(--danger); font-size: clamp(14px, 1.05vw, 20px); font-weight: 900; }
.trend.up { color: var(--success); }
.top .trend { color: white; }

.side-stack {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(12px, 1.1vh, 18px);
}
.pace-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(16px, 1.2vw, 23px);
  background: linear-gradient(160deg, #fff 0%, #fbf5ff 100%);
  border-color: #e7d4f6;
}
.pace-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.pace-header small { display: block; margin-top: 2px; color: var(--muted); font-size: clamp(9px, .62vw, 12px); }
.pace-badge {
  padding: 7px 10px;
  color: var(--success);
  background: var(--success-soft);
  border-radius: 9px;
  font-size: clamp(10px, .72vw, 14px);
  font-weight: 900;
  white-space: nowrap;
}
.pace-badge.behind { color: var(--danger); background: var(--danger-soft); }
.goal-amounts { margin-top: clamp(12px, 2vh, 25px); }
.goal-amounts strong { display: block; color: var(--brand-dark); font-size: clamp(29px, 2.8vw, 52px); line-height: 1; }
.goal-amounts span { display: block; margin-top: 6px; color: var(--muted); font-size: clamp(11px, .78vw, 15px); }
.goal-amounts b { color: var(--ink); }
.goal-track {
  position: relative;
  height: 17px;
  margin-top: clamp(14px, 1.8vh, 23px);
  overflow: visible;
  background: #ece2f3;
  border-radius: 99px;
}
.goal-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  border-radius: inherit;
  box-shadow: 0 5px 14px rgba(75,50,111,.2);
  transition: width 1.1s cubic-bezier(.2,.7,.2,1);
}
.goal-track i {
  position: absolute;
  top: -6px;
  width: 2px;
  height: 29px;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(199,138,34,.45);
  transition: right 1s ease;
}
.goal-track i::after { content: ""; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; background: var(--gold); border-radius: 50%; }
.goal-legend { display: flex; justify-content: space-between; margin-top: 10px; color: var(--muted); font-size: clamp(9px, .63vw, 12px); }
.legend-dot { display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; }
.legend-dot.actual { background: var(--brand); }
.legend-dot.required { background: var(--gold); }
.pace-divider { height: 1px; margin: clamp(12px, 1.7vh, 22px) 0; background: var(--line); }
.run-rate { display: flex; align-items: center; justify-content: space-between; }
.run-rate > div:first-child span { display: block; color: var(--muted); font-size: clamp(10px, .7vw, 14px); }
.run-rate > div:first-child strong { display: block; margin-top: 3px; color: var(--brand-dark); font-size: clamp(22px, 1.95vw, 37px); }
.run-rate-score {
  width: clamp(66px, 5.15vw, 96px);
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--brand-dark);
  background: white;
  border: 2px solid var(--brand);
  border-radius: 50%;
  box-shadow: 0 8px 22px rgba(75,50,111,.11);
}
.run-rate-score strong { color: var(--brand); font-size: clamp(18px, 1.35vw, 26px); line-height: 1; }
.run-rate-score span { color: var(--muted); font-size: clamp(8px, .54vw, 10px); }
.pace-message {
  margin: clamp(12px, 1.7vh, 21px) 0 0;
  padding: 10px 12px;
  color: #386f60;
  background: var(--success-soft);
  border-right: 4px solid var(--success);
  border-radius: 8px;
  font-size: clamp(10px, .7vw, 14px);
  line-height: 1.35;
}
.pace-message.behind { color: #954155; background: var(--danger-soft); border-color: var(--danger); }
.spotlight-panel { position: relative; overflow: hidden; padding: clamp(14px, 1.05vw, 19px); }
.spotlight-panel::after { content: ""; position: absolute; left: -70px; bottom: -100px; width: 180px; height: 180px; background: var(--brand); border-radius: 50%; filter: blur(75px); opacity: .09; }
.spotlight-content { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.trophy {
  width: clamp(45px, 3.3vw, 62px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 16px;
  font-size: clamp(22px, 1.65vw, 31px);
}
.spotlight-content span { display: block; color: var(--muted); font-size: clamp(9px, .63vw, 12px); }
.spotlight-content strong { display: block; color: var(--ink); font-size: clamp(18px, 1.42vw, 27px); line-height: 1.1; }
.spotlight-content small { color: var(--brand); font-size: clamp(10px, .68vw, 13px); font-weight: 800; }

.ticker-wrap {
  min-height: clamp(44px, 5.2vh, 61px);
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  overflow: hidden;
  color: white;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  border-radius: 15px;
  box-shadow: 0 10px 25px rgba(75,50,111,.19);
}
.ticker-title { height: 100%; display: flex; align-items: center; gap: 9px; padding: 0 18px; border-left: 1px solid rgba(255,255,255,.2); white-space: nowrap; font-size: clamp(10px, .7vw, 14px); font-weight: 800; }
.ticker-title .live-dot { background: white; box-shadow: 0 0 0 4px rgba(255,255,255,.15); }
.ticker-viewport { min-width: 0; overflow: hidden; direction: ltr; }
.ticker { display: inline-flex; gap: 30px; padding-left: 40px; white-space: nowrap; animation: ticker 35s linear infinite; }
.ticker-item { color: rgba(255,255,255,.78); font-size: clamp(10px, .7vw, 14px); }
.ticker-item strong { color: white; }
.ticker-item b { margin: 0 5px; color: white; }
.ticker-item::after { content: "•"; margin-left: 30px; color: rgba(255,255,255,.35); }
.refresh-note { padding: 0 16px; color: rgba(255,255,255,.62); border-right: 1px solid rgba(255,255,255,.2); white-space: nowrap; font-size: clamp(8px, .56vw, 11px); }

.error-screen { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(255,255,255,.94); backdrop-filter: blur(18px); }
.error-screen.hidden { display: none; }
.error-card { width: min(420px,90vw); padding: 38px; text-align: center; background: white; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.error-card > img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.error-card h2 { margin: 18px 0 5px; }
.error-card p { color: var(--muted); }
.error-card button { margin-top: 10px; padding: 10px 18px; color: white; background: var(--brand); border: 0; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 800; }

@keyframes pulse { 50% { opacity: .5; box-shadow: 0 0 0 8px rgba(112,80,168,0); } }
@keyframes rowIn { from { opacity: 0; transform: translateX(12px); } }
@keyframes ticker { to { transform: translateX(-50%); } }

@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 1fr; }
  .side-stack { display: none; }
  .center-status { display: none; }
}

@media (max-height: 800px) and (min-width: 1101px) {
  .leaderboard { gap: 3px; }
  .leader-row { padding-block: 1px; }
  .rank { width: 22px; border-radius: 7px; font-size: 10px; }
  .rep-cell { gap: 7px; }
  .avatar { width: 22px; border-radius: 7px; font-size: 9px; }
  .rep-cell strong { flex: 0 1 auto; font-size: 12px; line-height: 1; }
  .rep-cell small { flex: 0 1 auto; font-size: 8px; line-height: 1; }
  .table-value { font-size: 11px; line-height: 1; }
  .performance strong { font-size: 12px; line-height: 1; }
  .performance small { display: none; }
  .trend { font-size: 14px; line-height: 1; }
}
