:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e8edf3;
  --brand: #1e3a8a;
  --brand2: #2563eb;
  --brand-soft: #f2f6fd;
  --accent: #3b82f6;
  --gold: #eab308;
  --silver: #94a3b8;
  --bronze: #d08b52;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.05);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    Roboto,
    Arial,
    sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ===== layout ===== */
.wrap {
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px 24px 60px;
}
.page-title {
  margin: 6px 2px 18px;
}
.page-title h1 {
  font-size: 21px;
  margin: 0 0 4px;
  color: var(--brand);
  font-weight: 700;
}
.page-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* toolbar */
.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
select,
.btn {
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 14px;
  font-family: inherit;
}
select {
  padding: 0 32px 0 12px;
  background: #fff
    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='%2364748b' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  appearance: none;
  cursor: pointer;
  min-width: 130px;
  color: var(--ink);
}
.btn {
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  color: var(--ink);
}
.btn:hover {
  border-color: var(--accent);
  color: var(--brand2);
}
.btn.primary {
  background: var(--brand2);
  color: #fff;
  border-color: var(--brand2);
}
.btn.primary:hover {
  background: #1d4ed8;
  color: #fff;
}
.toolbar .spacer {
  margin-left: auto;
}
.search {
  position: relative;
}
.search input {
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0 14px 0 36px;
  font-size: 14px;
  width: 250px;
  font-family: inherit;
  background: #fff;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
}
.search svg {
  position: absolute;
  left: 11px;
  top: 11px;
  color: var(--muted);
}
.export {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  height: 38px;
  background: #fff;
}
.export button {
  border: none;
  background: transparent;
  height: 100%;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-left: 1px solid var(--line);
}
.export button:first-child {
  border-left: none;
}
.export button:hover {
  background: var(--brand-soft);
  color: var(--brand2);
}

/* секции */
.sec-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 4px 2px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sec-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* дашборд */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 15px 16px;
}
.stat .sl {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stat .sv {
  font-size: 25px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: -0.5px;
  color: var(--brand);
}
.stat .sd {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.chart-card h3 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.chart-card .hint {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}
.chart-wrap {
  position: relative;
  height: 300px;
}

/* таблица рейтинга */
.table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tbl-scroll {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
thead th {
  position: sticky;
  top: 0;
  background: #fbfcfe;
  z-index: 2;
  text-align: right;
  padding: 12px 16px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th.name {
  text-align: left;
}
thead th.rank {
  text-align: center;
}
thead th .arw {
  opacity: 0.35;
  font-size: 10px;
  margin-left: 3px;
}
thead th.sorted .arw {
  opacity: 1;
  color: var(--brand2);
}
tbody td {
  padding: 11px 16px;
  text-align: right;
  border-bottom: 1px solid #f2f5f9;
  white-space: nowrap;
  color: var(--ink);
}
tbody td.name {
  text-align: left;
  font-weight: 600;
  white-space: normal;
  min-width: 280px;
}
tbody td.rank {
  text-align: center;
}
tbody tr:hover td {
  background: #fafbfe;
}
.rk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  background: #eef2f7;
  color: var(--muted);
}
.rk.g1 {
  background: #fef9e7;
  color: #a16207;
  box-shadow: inset 0 0 0 1px #f5e08a;
}
.rk.g2 {
  background: #f1f5f9;
  color: #475569;
  box-shadow: inset 0 0 0 1px #cbd5e1;
}
.rk.g3 {
  background: #fbf0e6;
  color: #a55b23;
  box-shadow: inset 0 0 0 1px #e8c3a0;
}
.cnt {
  font-weight: 700;
}
/* мини-бар среднего балла */
.avgcell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.avgcell .v {
  font-weight: 700;
  min-width: 46px;
  text-align: right;
}
.bar {
  width: 96px;
  height: 7px;
  border-radius: 6px;
  background: #eef2f7;
  overflow: hidden;
  flex: none;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
}
.foot {
  padding: 12px 18px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.empty {
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
}
.nodata {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
}

/* мобильные карточки */
#cards {
  display: none;
  padding: 12px;
}
.ucard {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  background: #fff;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.ucard .uc-name {
  font-weight: 700;
  font-size: 13.5px;
  flex: 1;
  line-height: 1.35;
}
.uc-metrics {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}
.uc-metrics .m .ml {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}
.uc-metrics .m .mv {
  font-size: 15px;
  font-weight: 700;
}

/* адаптив */
@media (max-width: 900px) {
  .dash {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .wrap {
    padding: 16px 14px 48px;
  }
  .page-title h1 {
    font-size: 18px;
  }
  .toolbar {
    padding: 12px;
    gap: 10px;
  }
  .toolbar .field {
    flex: 1 1 calc(50% - 5px);
  }
  .toolbar select {
    width: 100%;
    min-width: 0;
  }
  .toolbar .spacer {
    display: none;
  }
  .search,
  .search input {
    width: 100%;
  }
  .toolbar .field.search-field {
    flex: 1 1 100%;
  }
  .export {
    flex: 1 1 100%;
  }
  .export button {
    flex: 1;
    justify-content: center;
  }
  .tbl-scroll {
    display: none;
  }
  #cards {
    display: block;
  }
  .foot {
    flex-direction: column;
    gap: 4px;
  }
}
@media print {
  .topbar,
  .toolbar,
  .dash,
  .sec-title {
    display: none;
  }
  body {
    padding-top: 0;
  }
}
