/* Рейтинг: тёмная тема dalbaeb.wf, токены из shared.css */

.rating-page {
  max-width: min(100% - 2.5rem, 96rem);
  margin: 0 auto;
  padding: 1.6rem 0 3rem;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 1.8rem 0 .9rem;
}

.section-title h2 { margin: 0; font-size: 1.05rem; font-weight: 750; letter-spacing: .04em; text-transform: none; }
.section-title small { color: var(--dim); font-size: .78rem; }

/* ── Метрики ── */

.rating-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }

.rating-metrics article {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-height: 5.4rem;
  padding: .85rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .6rem;
}

.rating-metrics span { color: var(--dim); font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: none; }
.rating-metrics strong { font-size: clamp(1.3rem, 2.2vw, 1.8rem); font-weight: 750; }
.rating-metrics small { color: var(--muted); font-size: .74rem; }
.rating-metrics .m-danger strong { color: var(--danger); }
.rating-metrics .m-warn strong { color: var(--gold); }
.rating-metrics .m-green strong { color: var(--green); }

/* ── Панель инструментов ── */

.rating-toolbar {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin: 1.4rem 0 .9rem;
}

.rating-search { position: relative; flex: 1 1 16rem; max-width: 26rem; }

.rating-search input {
  width: 100%;
  padding: .62rem .9rem .62rem 2.2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .5rem;
  color: var(--text);
  font: inherit;
  font-size: .9rem;
}

.rating-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

.rating-search::before {
  content: "⌕";
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-58%);
  color: var(--dim);
  font-size: 1.15rem;
  pointer-events: none;
}

.rating-refresh {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem 1rem;
  background: transparent;
  border: 1px solid var(--line-bright);
  border-radius: .5rem;
  color: var(--muted);
  font: inherit;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: none;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.rating-refresh:hover { color: var(--text); border-color: var(--accent); }
.rating-refresh[disabled] { opacity: .5; cursor: wait; }

.rating-updated { margin-left: auto; color: var(--dim); font-size: .75rem; text-align: right; }
.rating-updated b { color: var(--muted); font-weight: 600; }

/* ── Кланы ── */

.clans-block { margin-bottom: 1rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--panel); overflow: hidden; }

.clans-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: .7rem 1rem;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: none;
  cursor: pointer;
}

.clans-head:hover { color: var(--text); }
.clans-head i { font-style: normal; transition: transform .2s; }
.clans-block.open .clans-head i { transform: rotate(180deg); }

.clans-body { display: none; padding: .4rem 1rem 1rem; }
.clans-block.open .clans-body { display: block; }

.clans-body ol { margin: 0; padding: 0 0 0 1.2rem; columns: 3; column-gap: 2rem; color: var(--muted); font-size: .85rem; }
.clans-body li { padding: .18rem 0; break-inside: avoid; }
.clans-body b { color: var(--text); font-weight: 650; }
.clans-body span { color: var(--dim); font-size: .75rem; }

@media (max-width: 900px) { .clans-body ol { columns: 2; } }
@media (max-width: 600px) { .clans-body ol { columns: 1; } }

/* ── Таблица ── */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: .6rem;
  overflow: auto;
  background: var(--panel);
  max-height: 72vh;
}

table.rating { width: 100%; border-collapse: collapse; font-size: .88rem; }

table.rating thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: .65rem .8rem;
  background: var(--panel-raised);
  border-bottom: 1px solid var(--line-bright);
  color: var(--dim);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: none;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

table.rating thead th.sortable { cursor: pointer; }
table.rating thead th.sortable:hover { color: var(--text); }
table.rating thead th .arrow { color: var(--accent); margin-left: .25em; }

table.rating tbody td { padding: .5rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
table.rating tbody tr { cursor: pointer; transition: background .12s; }
table.rating tbody tr:hover { background: var(--panel-soft); }
table.rating tbody tr.selected { background: var(--panel-soft); box-shadow: inset 3px 0 0 var(--accent); }

td.cell-place { color: var(--dim); font-family: var(--font); font-size: .8rem; }

.cell-league { display: flex; align-items: center; gap: .55rem; }
.cell-league img { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; }
.cell-league b { font-family: var(--font); font-size: .84rem; }
.cell-league small { display: block; color: var(--dim); font-size: .66rem; }

.cell-player { display: flex; align-items: center; gap: .6rem; min-width: 15rem; }
.cell-player img { width: 32px; height: 32px; object-fit: contain;  flex-shrink: 0; }
.cell-player .names { display: grid; min-width: 0; }
.cell-player .nick { font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.cell-player .nick a { color: var(--text); text-decoration: none; }
.cell-player .nick a:hover { color: var(--accent-bright); }
.cell-player .sub { color: var(--dim); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; }

.clan-pill {
  display: inline-block;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 1px 7px;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .66rem;
  letter-spacing: .04em;
}

td.cell-rp, td.cell-pts { font-family: var(--font); font-size: .84rem; }
td.cell-rp small, td.cell-pts small { display: block; color: var(--dim); font-size: .66rem; }

.cheat-cell { display: flex; align-items: center; gap: .55rem; min-width: 10.5rem; }
.cheat-emoji { font-size: 1rem; }

.cheat-bar {
  position: relative;
  flex: 1;
  height: 6px;
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  overflow: hidden;
}

.cheat-bar i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; }
.cheat-cell b { font-family: var(--font); font-size: .8rem; min-width: 2.4rem; text-align: right; }

.row-action { padding: .25rem .6rem; border: 1px solid var(--line-bright); border-radius: .4rem; color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: none; text-decoration: none; white-space: nowrap; }
.row-action:hover { color: var(--accent-bright); border-color: var(--accent); }

.empty-row { padding: 2.5rem 1rem !important; text-align: center; color: var(--dim); cursor: default !important; }

/* ── Изменения ── */

.changes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

.change-col { border: 1px solid var(--line); border-radius: .6rem; background: var(--panel); overflow: hidden; }

.change-col h3 {
  margin: 0;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: none;
  color: var(--muted);
}

.change-col h3 b { color: var(--text); }

.change-col ul { margin: 0; padding: .4rem 0; list-style: none; max-height: 21rem; overflow: auto; }

.change-col li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .4rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: .82rem;
}

.change-col li:last-child { border-bottom: 0; }
.change-col .place { color: var(--dim); font-family: var(--font); font-size: .74rem; min-width: 3.2rem; }
.change-col .nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.change-col .delta { margin-left: auto; color: var(--dim); font-family: var(--font); font-size: .72rem; white-space: nowrap; }
.change-col .when { color: var(--dim); font-size: .68rem; }

.col-appeared .place { color: var(--green); }
.col-disappeared .place { color: var(--danger); }

.changes-empty { padding: 1.4rem 1rem; color: var(--dim); font-size: .82rem; text-align: center; }

/* ── Карточка игрока ── */

.player-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(4, 7, 13, .6);
  
}

.player-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 501;
  width: min(30rem, 94vw);
  background: var(--bg-deep);
  border-left: 1px solid var(--line-bright);
  overflow-y: auto;
  padding: 1.2rem 1.4rem 2rem;
  box-shadow: -18px 0 44px rgba(0, 0, 0, .45);
}

.player-drawer .close {
  position: absolute;
  top: .8rem;
  right: .9rem;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
}

.player-drawer .close:hover { color: var(--text); border-color: var(--accent); }

.pd-head { display: flex; align-items: center; gap: .8rem; margin: .4rem 0 1rem; }
.pd-head img { width: 52px; height: 52px; object-fit: contain;  }
.pd-head h3 { margin: 0; font-size: 1.3rem; font-weight: 750; word-break: break-word; }
.pd-head small { color: var(--muted); }

.pd-verdict {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .8rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: var(--panel);
}

.pd-verdict .emoji { font-size: 1.7rem; }
.pd-verdict b { display: block; font-size: .95rem; }
.pd-verdict small { color: var(--muted); }
.pd-verdict .pct { margin-left: auto; font-family: var(--font); font-size: 1.5rem; font-weight: 750; }

.pd-facts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.pd-facts div { padding: .55rem .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: .5rem; }
.pd-facts span { display: block; color: var(--dim); font-size: .62rem; letter-spacing: .1em; text-transform: none; }
.pd-facts b { font-size: .95rem; font-weight: 650; }

.pd-reasons { margin: 0 0 1.1rem; padding: 0; list-style: none; display: grid; gap: .3rem; }

.pd-reasons li {
  padding: .45rem .7rem;
  border-left: 3px solid var(--line-bright);
  background: var(--panel);
  border-radius: 0 .4rem .4rem 0;
  color: var(--muted);
  font-size: .82rem;
}

.pd-reasons li.neg { border-left-color: var(--danger); color: var(--text); }
.pd-reasons li.pos { border-left-color: var(--green); }

.pd-chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.pd-chart-head h4 { margin: 0; font-size: .72rem; letter-spacing: .12em; text-transform: none; color: var(--dim); }

.chart-mode { display: inline-flex; border: 1px solid var(--line-bright); border-radius: .45rem; overflow: hidden; }
.chart-mode button { padding: .3rem .7rem; background: none; border: 0; color: var(--muted); font: inherit; font-size: .7rem; font-weight: 700; cursor: pointer; }
.chart-mode button.active { background: var(--panel-soft); color: var(--text); }

canvas.pd-canvas { width: 100%; height: 12rem; background: var(--panel); border: 1px solid var(--line); border-radius: .5rem; }

.pd-profile-link {
  display: block;
  margin-top: 1.1rem;
  padding: .7rem;
  border: 1px solid var(--line-bright);
  border-radius: .5rem;
  color: var(--accent-bright);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: center;
  text-decoration: none;
  text-transform: none;
}

.pd-profile-link:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ── Состояния ── */

.state-box { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.state-box.error { color: var(--danger); }
.state-box .spin { display: inline-block; width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; margin-bottom: .8rem; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .rating-metrics { grid-template-columns: repeat(2, 1fr); }
  .changes-grid { grid-template-columns: 1fr; }
  .rating-page { max-width: min(100% - 1.4rem, 96rem); }
}

@media (max-width: 560px) {
  .rating-metrics { grid-template-columns: 1fr 1fr; }
  .rating-updated { width: 100%; margin: 0; text-align: left; }
}

.rating-page { max-width: var(--content); padding-top: 2rem; }
.section-title { margin-top: 0; margin-bottom: 1.5rem; gap: .75rem; }
.section-title h1 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.5rem); font-weight: 600; letter-spacing: -.035em; }
.section-title h2 { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; }
.section-title small { font-size: .85rem; color: var(--muted); }
.release-tag { display: inline-block; vertical-align: middle; margin-left: .5rem; padding: .2rem .5rem; border: 1px solid var(--line-bright); border-radius: var(--radius-sm); color: var(--muted); font-size: .75rem; font-weight: 400; letter-spacing: 0; }
.rating-metrics { gap: 1rem; }
.rating-metrics article { min-height: 7rem; padding: 1.1rem 1.25rem; border-radius: var(--radius); }
.rating-metrics span { font-size: .85rem; letter-spacing: 0; font-weight: 400; color: var(--muted); }
.rating-metrics strong { font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.rating-metrics small { font-size: .8rem; }
.rating-metrics .m-green strong { color: var(--text); }
.rating-toolbar { margin-block: 1.5rem 1rem; }
.rating-search input, .rating-refresh { min-height: 44px; font-size: .9rem; border-radius: var(--radius-sm); }
.rating-refresh { letter-spacing: 0; font-weight: 500; }
.rating-refresh { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rating-refresh:hover { background: var(--accent-bright); border-color: var(--accent-bright); color: var(--accent-ink); }
.rating-metrics article:first-child { border-top: 2px solid var(--accent); }
.rating-metrics article:first-child strong { color: var(--accent); }
.rating-updated { font-size: .8rem; }
.clans-head { min-height: 48px; font-size: .85rem; letter-spacing: 0; font-weight: 500; }
.clans-body ol { line-height: 1.8; }
.table-wrap { --table-surface: #0f1a2a; border-radius: var(--radius); max-height: 70vh; background: var(--table-surface); }
table.rating tbody tr.risk-medium { background: color-mix(in srgb, var(--gold) 6%, var(--table-surface)); }
table.rating tbody tr.risk-high { background: color-mix(in srgb, var(--danger) 9%, var(--table-surface)); }
table.rating tbody tr:hover, table.rating tbody tr.selected { background: color-mix(in srgb, var(--accent) 8%, var(--table-surface)); }
table.rating { font-size: .9rem; }
table.rating thead th { color: var(--muted); font-size: .8rem; letter-spacing: 0; font-weight: 500; padding: 1rem; }
table.rating tbody td { padding: .8rem 1rem; }
td.cell-place { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.cell-league b, td.cell-rp, td.cell-pts { font-size: .9rem; font-variant-numeric: tabular-nums; }
.cell-league small, .cell-player .sub, td.cell-rp small, td.cell-pts small { color: var(--dim); font-size: .75rem; }
.cell-player { min-width: 14rem; }
.clan-pill { padding: 0; border: 0; border-radius: 0; font-size: .75rem; letter-spacing: 0; vertical-align: bottom; }
.row-action { display: inline-flex; align-items: center; min-height: 36px; padding: .35rem .7rem; font-size: .8rem; font-weight: 500; letter-spacing: 0; }
.cheat-cell { min-width: 10rem; }
.risk-low { --risk: var(--dim); }
.risk-watch { --risk: var(--green); }
.risk-medium { --risk: var(--gold); }
.risk-high { --risk: var(--danger); }
.risk-dot { display: inline-block; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--risk); }
.cheat-cell b { color: var(--risk); font-size: .85rem; font-variant-numeric: tabular-nums; }
progress.cheat-bar { appearance: none; display: block; border: 0; height: 4px; border-radius: 2px; background: var(--panel-soft); }
progress.cheat-bar::-webkit-progress-bar { background: var(--panel-soft); border-radius: 2px; }
progress.cheat-bar::-webkit-progress-value { background: var(--risk); border-radius: 2px; }
progress.cheat-bar::-moz-progress-bar { background: var(--risk); border-radius: 2px; }
.table-wrap + .section-title { margin-top: 2.5rem; }
.change-col { border-radius: var(--radius); }
.change-col h3 { padding: 1rem; font-size: .85rem; letter-spacing: 0; font-weight: 500; }
.changes-empty { font-size: .85rem; }
.drawer-open { overflow: hidden; }
.player-drawer { width: min(34rem, 100vw); padding: 2rem 1.5rem; background: var(--bg); box-shadow: none; }
.player-drawer .close { width: 44px; height: 44px; top: 1rem; right: 1rem; background: var(--panel); }
.pd-head { padding-right: 2.5rem; margin-bottom: 1.5rem; }
.pd-head h3 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.03em; }
.pd-head small { display: block; margin-top: .35rem; font-size: .85rem; }
.pd-verdict { padding: 1.1rem; border-radius: var(--radius); }
.pd-verdict .pct { color: var(--risk); font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.pd-facts div { padding: 1rem; border-radius: var(--radius-sm); }
.pd-facts span { font-size: .8rem; letter-spacing: 0; }
.pd-facts b { font-size: 1.25rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.pd-reasons-title, .pd-chart-head h4 { color: var(--muted); font-size: .85rem; font-weight: 500; letter-spacing: 0; margin: 1.5rem 0 .75rem; }
.pd-reasons li { padding: .75rem; font-size: .9rem; line-height: 1.5; }
.pd-chart-head { margin-top: 1.5rem; }
.pd-chart-head h4 { margin: 0; }
.chart-mode button { min-height: 40px; padding-inline: 1rem; font-size: .85rem; }
.pd-profile-link { padding: .85rem; font-size: .9rem; font-weight: 500; letter-spacing: 0; }
.state-box { min-height: 20rem; display: grid; place-content: center; }
@media (max-width: 560px) {
  .rating-page { padding-top: 1.5rem; }
  .rating-metrics { gap: .65rem; }
  .rating-metrics article { padding: 1rem; min-height: 7rem; }
  .rating-metrics span { font-size: .8rem; }
  .rating-search { max-width: none; }
  .rating-refresh { flex: 1; justify-content: center; }
  .row-action { min-height: 44px; }
  .player-drawer { padding-inline: 1rem; }
}

.rating-search::before { content: ""; width: 12px; height: 12px; border: 1.5px solid var(--dim); border-radius: 50%; transform: translateY(-60%); }
.rating-search::after { content: ""; position: absolute; left: 1.28rem; top: calc(50% + 4px); width: 6px; height: 1.5px; background: var(--dim); transform: rotate(45deg); pointer-events: none; }
