:root {
  --bg: #0a0d12;
  --bg-1: #0e1218;
  --bg-2: #131820;
  --bg-3: #19202b;
  --line: #1f2735;
  --line-2: #2a3342;
  --text: #e8edf4;
  --muted: #8794a8;
  --dim: #5a6577;
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --cta: #f97316;
  --cta-2: #fb923c;
  --good: #22c55e;
  --warn: #eab308;
  --bad: #ef4444;
  --info: #06b6d4;

  --r-1: 6px;
  --r-2: 10px;
  --r-3: 14px;
  --r-4: 20px;

  --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;  --s8: 64px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.5), 0 1px 1px rgba(0,0,0,.25);
  --shadow-2: 0 8px 24px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.3);
  --shadow-glow: 0 0 0 1px rgba(59,130,246,.25), 0 8px 32px rgba(59,130,246,.18);

  --sidebar-w: 240px;
  --topbar-h: 64px;
  --bottom-nav-h: 64px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --safe-bottom: env(safe-area-inset-bottom);
  --safe-top: env(safe-area-inset-top);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

code, .mono { font-family: var(--mono); }

/* ───── Layout ───── */

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: var(--s4) 0;
  z-index: 50;
  transition: transform .25s ease;
}

.sidebar__brand {
  padding: var(--s2) var(--s4) var(--s5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}

.brand__logo {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--cta));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.brand__name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.brand__sub {
  color: var(--dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-family: var(--mono);
}

.sidebar__close {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: var(--r-1);
  cursor: pointer;
}

.nav {
  display: flex;
  flex-direction: column;
  padding: 0 var(--s2);
  gap: 2px;
  flex: 1;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s3);
  border-radius: var(--r-2);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s ease;
}

.nav__item:hover {
  background: var(--bg-2);
  color: var(--text);
  text-decoration: none;
}

.nav__item.is-active {
  background: rgba(59,130,246,.1);
  color: var(--accent-2);
}

.nav__item.is-active::before {
  content: "";
  width: 3px; height: 18px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: 6px;
  margin-left: -8px;
}

.nav__item svg { flex-shrink: 0; }

.sidebar__footer {
  padding: var(--s4);
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.user-chip__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  display: grid;
  place-items: center;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.user-chip__info {
  flex: 1;
  min-width: 0;
}

.user-chip__name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip__role {
  font-size: 11px;
  color: var(--dim);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  z-index: 49;
}

.sidebar-backdrop.is-open {
  display: block;
}

/* ───── Topbar ───── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  margin-left: var(--sidebar-w);
  background: rgba(10,13,18,.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s5);
}

.topbar__menu {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: var(--r-2);
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
}

.topbar__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.topbar__sep {
  color: var(--dim);
  font-weight: 400;
}

.topbar__updated {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.back-link {
  color: var(--muted);
  font-size: 14px;
}
.back-link:hover { color: var(--text); text-decoration: none; }

/* ───── Content ───── */

.content {
  margin-left: var(--sidebar-w);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  padding-bottom: calc(var(--s7) + var(--bottom-nav-h));
}

@media (min-width: 1024px) {
  .content { padding-bottom: var(--s7); }
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s5);
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ───── Cards ───── */

.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s5);
  box-shadow: var(--shadow-1);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}

.card__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

/* ───── Metrics ───── */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s4);
}

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

.metric {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

.metric--accent {
  background: linear-gradient(135deg, rgba(59,130,246,.14), rgba(96,165,250,.05));
  border-color: rgba(59,130,246,.4);
}

.metric--cta {
  background: linear-gradient(135deg, rgba(249,115,22,.14), rgba(251,146,60,.05));
  border-color: rgba(249,115,22,.4);
}

.metric__label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}

.metric__value {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.metric__unit {
  font-size: 18px;
  color: var(--muted);
  margin-left: 2px;
}

.metric__sub {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}

/* ───── Funnel ───── */

.funnel {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.funnel__step {
  display: grid;
  grid-template-columns: 160px 1fr 80px;
  gap: var(--s3);
  align-items: center;
  padding: var(--s3) var(--s4);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  position: relative;
}

.funnel__name {
  font-weight: 500;
  font-size: 14px;
}

.funnel__bar {
  height: 12px;
  background: var(--bg-3);
  border-radius: 6px;
  overflow: hidden;
}

.funnel__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 6px;
  transition: width .4s ease;
}

.funnel__count {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text);
}

.funnel__count small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

@media (max-width: 700px) {
  .funnel__step { grid-template-columns: 1fr 60px; gap: var(--s2); padding: var(--s3); }
  .funnel__name { grid-column: 1 / -1; font-size: 13px; }
  .funnel__bar { grid-column: 1 / 2; }
  .funnel__count { grid-column: 2 / 3; }
}

/* ───── Charts ───── */

.chart-wrap {
  position: relative;
  height: 280px;
}

.chart-wrap--sm {
  height: 220px;
}

@media (max-width: 600px) {
  .chart-wrap { height: 240px; }
  .chart-wrap--sm { height: 200px; }
}

.legend {
  display: flex;
  gap: var(--s4);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.legend__dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.legend__dot--users { background: var(--accent); }
.legend__dot--clicks { background: var(--cta); }
.legend__dot--active { background: var(--good); }

/* ───── Tables ───── */

.table-wrap {
  overflow-x: auto;
  margin: 0 calc(var(--s5) * -1);
  padding: 0 var(--s5);
}

.table-wrap--rich .table {
  display: table;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th, .table td {
  padding: var(--s3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: var(--bg-2);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table td {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.table td.num { text-align: right; }

.table tbody tr {
  transition: background .12s ease;
  cursor: pointer;
}

.table tbody tr:hover { background: var(--bg-2); }

.table--users td:first-child { min-width: 200px; }

.url {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.url a { color: var(--muted); }
.url a:hover { color: var(--accent); }

/* Card-style on mobile */
.cards { display: none; flex-direction: column; gap: var(--s3); padding: var(--s2) 0; }

@media (max-width: 768px) {
  .table-wrap--rich .table { display: none; }
  .table-wrap--rich .cards { display: flex; }
  .table-wrap { margin: 0; padding: 0; }
}

.row-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  cursor: pointer;
}

.row-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.row-card__title {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}

.row-card__id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.row-card__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2) var(--s4);
  font-size: 12px;
}

.row-card__cell label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 2px;
}

.row-card__cell span {
  font-family: var(--mono);
}

/* ───── Badges & tags ───── */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--mono);
  background: var(--bg-2);
  color: var(--muted);
  border: 1px solid var(--line);
  letter-spacing: .02em;
}

.tag--lang-hy { color: #fbbf24; border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.08); }
.tag--lang-ru { color: #60a5fa; border-color: rgba(96,165,250,.35); background: rgba(96,165,250,.08); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  background: var(--bg-3);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.badge--good { background: rgba(34,197,94,.15); color: var(--good); }
.badge--cta { background: rgba(249,115,22,.15); color: var(--cta); }
.badge--info { background: rgba(6,182,212,.15); color: var(--info); }
.badge--warn { background: rgba(234,179,8,.15); color: var(--warn); }
.badge--bad { background: rgba(239,68,68,.15); color: var(--bad); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.status--clicker { color: var(--cta); }
.status--active { color: var(--good); }
.status--cold { color: var(--dim); }
.status--no-click { color: var(--muted); }

/* ───── Buttons & inputs ───── */

.btn {
  appearance: none;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-2);
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 38px;
}

.btn:hover:not(:disabled) {
  border-color: var(--line-2);
  background: var(--bg-3);
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: white;
  font-weight: 600;
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn--danger {
  background: linear-gradient(135deg, var(--bad), #f87171);
  border-color: transparent;
  color: white;
  font-weight: 600;
}

.btn--ghost { background: transparent; }

.btn--lg {
  padding: 12px 20px;
  font-size: 14px;
  min-height: 46px;
}

.btn-icon {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 38px; height: 38px;
  border-radius: var(--r-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .15s ease;
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--line-2);
  background: var(--bg-2);
}

.input, .select {
  appearance: none;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  width: 100%;
  font-family: var(--font);
  transition: border-color .15s ease;
}

.input::placeholder { color: var(--dim); }

.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
}

.input--ghost {
  background: transparent;
  border-color: transparent;
  padding-left: 36px;
}

.input--textarea {
  font-family: var(--font);
  resize: vertical;
  min-height: 140px;
  line-height: 1.55;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238794a8' stroke-width='2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.field__label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .02em;
}

.field__hint {
  font-size: 12px;
  color: var(--dim);
}

.codeblock {
  display: inline-block;
  background: var(--bg-2);
  padding: 4px 8px;
  border-radius: var(--r-1);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  margin-top: 4px;
}

/* ───── Toolbar ───── */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}

.toolbar__search {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.toolbar__search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.toolbar__search .input {
  background: var(--bg-2);
  border-color: var(--line);
}

.toolbar__filters {
  display: flex;
  gap: var(--s2);
}

.toolbar--multi {
  display: grid;
  grid-template-columns: 1fr repeat(3, minmax(140px, 200px));
  gap: var(--s3);
}

@media (max-width: 900px) {
  .toolbar--multi { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 500px) {
  .toolbar--multi { grid-template-columns: 1fr; }
}

/* ───── Pager ───── */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  margin-top: var(--s4);
}

.pager__info {
  color: var(--muted);
  font-size: 13px;
  font-family: var(--mono);
  min-width: 140px;
  text-align: center;
}

/* ───── Sections list ───── */

.sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--s3);
}

.section-item {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.section-item__name {
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
}

.section-item__stats {
  display: flex;
  gap: var(--s4);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.section-item__bar {
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
}

.section-item__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
}

/* ───── Feed (events / clicks list) ───── */

.feed {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.feed-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--s3);
  padding: var(--s3);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  align-items: start;
  cursor: pointer;
  transition: border-color .15s ease;
}

.feed-item:hover {
  border-color: var(--line-2);
}

.feed-item__time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.feed-item__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.feed-item__main {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  font-size: 13px;
}

.feed-item__sub {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
  word-break: break-all;
}

.feed--timeline .feed-item {
  position: relative;
  padding-left: var(--s5);
}

.feed--timeline .feed-item::before {
  content: "";
  position: absolute;
  left: 12px; top: 22px;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-1);
}

@media (max-width: 600px) {
  .feed-item { grid-template-columns: 1fr; }
}

/* ───── Profile (user detail) ───── */

.profile {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

.profile-loading {
  color: var(--muted);
  padding: var(--s5);
  text-align: center;
}

.profile__header {
  display: flex;
  align-items: center;
  gap: var(--s4);
  flex-wrap: wrap;
}

.profile__avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cta));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 22px;
  color: white;
  flex-shrink: 0;
}

.profile__main {
  flex: 1;
  min-width: 0;
}

.profile__name {
  font-size: 18px;
  font-weight: 600;
}

.profile__sub {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  gap: var(--s3);
  flex-wrap: wrap;
}

.profile__id { display: inline-flex; align-items: center; gap: 6px; }

.profile__actions {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

.profile-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--s2);
  padding: var(--s3) 0;
}

.chip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chip__label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.chip__value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chip--good { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.35); }
.chip--good .chip__value { color: var(--good); }
.chip--cta { background: rgba(249,115,22,.1); border-color: rgba(249,115,22,.35); }
.chip--cta .chip__value { color: var(--cta); }

.profile__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s3);
}

.profile-item {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s3) var(--s4);
}

.profile-item__label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}

.profile-item__value {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-word;
}

/* ───── CTR grid (clicks / content sections) ───── */

.ctr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s3);
}

.ctr-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.ctr-card__name {
  font-weight: 600;
  font-size: 14px;
  text-transform: capitalize;
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.ctr-card__metric {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ctr-card__sub {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  display: flex;
  gap: var(--s3);
  flex-wrap: wrap;
}

/* ───── Leaderboard / Podium ───── */

.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: var(--s3);
  align-items: end;
  margin-bottom: var(--s5);
}

@media (max-width: 600px) {
  .podium { grid-template-columns: 1fr; gap: var(--s3); }
}

.podium__slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s4);
  border-radius: var(--r-3);
  border: 1px solid var(--line);
  background: var(--bg-2);
  position: relative;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease;
  text-align: center;
}

.podium__slot:hover { transform: translateY(-2px); border-color: var(--line-2); }

.podium__slot--gold {
  background: linear-gradient(180deg, rgba(234,179,8,.18), rgba(234,179,8,.04));
  border-color: rgba(234,179,8,.5);
  order: 2;
  padding-top: var(--s5);
  padding-bottom: var(--s5);
  box-shadow: 0 4px 24px rgba(234,179,8,.18);
}

.podium__slot--silver {
  background: linear-gradient(180deg, rgba(180,180,200,.14), rgba(180,180,200,.02));
  border-color: rgba(180,180,200,.4);
  order: 1;
  padding-bottom: var(--s4);
  margin-top: var(--s4);
}

.podium__slot--bronze {
  background: linear-gradient(180deg, rgba(205,127,50,.16), rgba(205,127,50,.02));
  border-color: rgba(205,127,50,.4);
  order: 3;
  padding-bottom: var(--s4);
  margin-top: var(--s5);
}

@media (max-width: 600px) {
  .podium__slot--gold, .podium__slot--silver, .podium__slot--bronze {
    order: initial;
    margin-top: 0;
    padding: var(--s4);
  }
}

.podium__rank {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.podium__slot--gold .podium__rank { color: #fbbf24; }
.podium__slot--silver .podium__rank { color: #cbd5e1; }
.podium__slot--bronze .podium__rank { color: #f59e6b; }

.podium__avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cta));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 22px;
  color: white;
  border: 2px solid var(--bg-1);
}

.podium__slot--gold .podium__avatar {
  width: 72px; height: 72px;
  font-size: 28px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.podium__name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.podium__metric {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.podium__slot--gold .podium__metric { font-size: 28px; color: #fbbf24; }

.podium__sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.podium__medal {
  position: absolute;
  top: -10px;
  right: 12px;
  font-size: 22px;
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.lb-row {
  display: grid;
  grid-template-columns: 50px 40px 1fr auto auto;
  gap: var(--s3);
  align-items: center;
  padding: var(--s3) var(--s4);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  cursor: pointer;
  transition: border-color .15s ease;
}

.lb-row:hover { border-color: var(--line-2); }

.lb-row__rank {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.lb-row__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cta));
  display: grid;
  place-items: center;
  font-weight: 600;
  color: white;
  font-size: 14px;
}

.lb-row__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.lb-row__name {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-row__sub {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-row__metric {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.lb-row__lang { display: none; }

@media (min-width: 600px) {
  .lb-row__lang { display: inline-flex; }
}

@media (max-width: 600px) {
  .lb-row { grid-template-columns: 36px 36px 1fr auto; }
  .lb-row__rank { font-size: 13px; }
}

/* ───── Tabs ───── */

.tabs {
  display: flex;
  gap: var(--s2);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: var(--r-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
}

.tab:hover { color: var(--text); border-color: var(--line-2); }
.tab.is-active { background: var(--bg-2); color: var(--text); border-color: var(--line-2); }

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--s3);
}

.media-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s3) var(--s4);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.media-card__name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  word-break: break-all;
}

.media-card__meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  display: flex;
  gap: var(--s3);
}

/* ───── Broadcast ───── */

.form { display: flex; flex-direction: column; gap: var(--s4); }

.form--broadcast { max-width: 720px; }

.bc-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
}

.bc-preview {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s4);
}

.bc-preview__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: var(--s2);
}

.bc-preview__bubble {
  background: linear-gradient(135deg, #1a3a6e, #1e4488);
  border-radius: 14px 14px 14px 4px;
  padding: var(--s3) var(--s4);
  white-space: pre-wrap;
  font-size: 14px;
  color: white;
  max-width: 480px;
  word-break: break-word;
}

/* ───── Modal ───── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--s4);
}

.modal[hidden] { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
}

.modal__card {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s5);
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  box-shadow: var(--shadow-2);
}

.modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.modal__body {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s3);
}

/* ───── Toast ───── */

#toast-host {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--s4));
  right: var(--s4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}

@media (min-width: 1024px) {
  #toast-host { bottom: var(--s4); }
}

.toast {
  pointer-events: auto;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  padding: var(--s3) var(--s4);
  font-size: 13px;
  box-shadow: var(--shadow-2);
  animation: slideIn .25s ease;
  max-width: 320px;
}

.toast--good { border-color: rgba(34,197,94,.35); background: rgba(34,197,94,.1); }
.toast--bad { border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.1); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ───── Bottom nav (mobile) ───── */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(10,13,18,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  height: var(--bottom-nav-h);
  padding-bottom: var(--safe-bottom);
  z-index: 40;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 4px;
}

.bottom-nav__item.is-active {
  color: var(--accent-2);
}

.bottom-nav__item:hover { text-decoration: none; }

@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar__close { display: grid; place-items: center; }
  .topbar { margin-left: 0; padding: 0 var(--s3); }
  .topbar__menu { display: flex; }
  .content { margin-left: 0; padding: var(--s3); padding-bottom: calc(var(--bottom-nav-h) + var(--s5) + var(--safe-bottom)); }
  .bottom-nav { display: flex; }
  .table-wrap { margin: 0 calc(var(--s3) * -1); padding: 0 var(--s3); }
  .metrics { gap: var(--s3); }
  .card { padding: var(--s4); }
  .metric { padding: var(--s4); }
}

@media (max-width: 480px) {
  .topbar__title { font-size: 16px; }
  .metric__value { font-size: 26px; }
}

/* ───── Login ───── */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--s4);
  background:
    radial-gradient(circle at 20% 30%, rgba(59,130,246,.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(249,115,22,.12) 0%, transparent 50%),
    var(--bg);
}

.login-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s7);
  max-width: 960px;
  width: 100%;
  align-items: center;
}

@media (max-width: 768px) {
  .login-shell { grid-template-columns: 1fr; gap: var(--s4); }
}

.login-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s6);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.login-card__brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s3);
}

.login-card__title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.login-card__hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.login-side { display: none; }

@media (min-width: 769px) {
  .login-side { display: block; }
}

.login-side__title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: var(--s4);
  background: linear-gradient(135deg, var(--text), var(--muted));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-side__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  color: var(--muted);
  font-size: 14px;
}

.login-side__list li {
  padding-left: 28px;
  position: relative;
}

.login-side__list li::before {
  content: "";
  position: absolute;
  left: 0; top: 6px;
  width: 16px; height: 16px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--cta));
}

.alert {
  border-radius: var(--r-2);
  padding: var(--s3) var(--s4);
  font-size: 13px;
}

.alert--error {
  background: rgba(239,68,68,.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.3);
}

.link {
  font-size: 13px;
  color: var(--accent-2);
}

/* ───── Reduced motion ───── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ───── Skeleton ───── */

.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-1);
  height: 14px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty {
  text-align: center;
  padding: var(--s7);
  color: var(--muted);
  font-size: 13px;
}
