@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&family=Playfair+Display:ital,wght@0,500;0,600;0,700;0,900;1,600&display=swap");

:root {
  --ink: #0d0c5c;
  --ink-soft: #201e78;
  --paper: #f7f7fb;
  --card: #ffffff;
  --accent: #ffac33;
  --accent-dark: #d98a17;
  --accent-tint: #fff2dd;
  --gold: #c9932c;
  --gold-tint: #fbf1dc;
  --silver: #8b8fa0;
  --silver-tint: #f1f2f5;
  --bronze: #b06a3e;
  --bronze-tint: #f7ebe2;
  --text: #15142f;
  --muted: #7c7c93;
  --border: #e7e7ef;
  --green: #1c9a56;
  --red: #d6493d;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 16px 40px -20px rgba(23, 19, 33, 0.35);
  --shadow-sm: 0 6px 18px -10px rgba(23, 19, 33, 0.22);
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
}

body {
  background: var(--paper);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
}

a { color: inherit; }

/* ---------- utility bar ---------- */

.utility-bar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  transition: border-color .15s, color .15s;
}

.home-btn:hover { border-color: var(--ink); color: var(--ink); }

.lang-toggle {
  display: inline-flex;
  gap: 2px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  margin-left: auto;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.lang-btn.active { background: var(--ink); color: #fff; }

.lang-btn:not(.active):hover { color: var(--ink); }

/* ---------- hero ---------- */

.hero {
  background: var(--card);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: 26px 24px 22px;
}

.hero-inner {
  max-width: 1080px;
  margin: 0 auto;
}

.eyebrow {
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.hero h1 {
  font-family: var(--sans);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 10px;
}

.lede {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

/* ---------- layout ---------- */

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 24px 70px;
  position: relative;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: start;
}

.layout-main {
  min-width: 0;
}

/* ---------- пошук закладу ---------- */

.search-row {
  margin-bottom: 16px;
}

.uni-search-input {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 11px 18px;
}

.uni-search-input:focus {
  outline: none;
  border-color: var(--ink);
}

/* ---------- year selector ---------- */

.year-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.year-row-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  flex: none;
}

.year-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.year-chip {
  flex: none;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.year-chip:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- priority filter toggle ---------- */

.priority-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.priority-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.priority-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.priority-toggle-track {
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--border);
  position: relative;
  transition: background .15s;
}

.priority-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .15s;
}

.priority-toggle input:checked ~ .priority-toggle-track {
  background: var(--accent-dark);
}

.priority-toggle input:checked ~ .priority-toggle-track .priority-toggle-thumb {
  transform: translateX(16px);
}

.priority-toggle input:focus-visible ~ .priority-toggle-track {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.priority-toggle-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.year-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ---------- stat tiles ---------- */

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.stat-tile {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: opacity .2s;
  min-width: 0;
}

.stat-tile.dim { opacity: 0.45; }

.stat-label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---------- controls: tabs + date chips ---------- */

.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}

.tabs-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tabs-sm { padding: 3px; }

.tabs-sm .pill {
  padding: 7px 13px;
  font-size: 12.5px;
}

.view-hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  margin: -14px 0 18px;
}

.tabs {
  position: relative;
  display: inline-flex;
  gap: 2px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  width: fit-content;
}

.tabs-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  background: var(--ink);
  border-radius: var(--radius-pill);
  transition: left .25s cubic-bezier(.4,0,.2,1), width .25s cubic-bezier(.4,0,.2,1);
  z-index: 0;
}

.pill {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  padding: 9px 22px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color .15s;
}

.pill.active { color: #fff; }

.pill:not(.active):hover { color: var(--ink); }

.date-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.date-chips::-webkit-scrollbar { display: none; }

.date-chip {
  flex: none;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.date-chip:hover { border-color: var(--ink); color: var(--ink); }

.date-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.caption {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 22px;
}

.sort-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.sort-row-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  flex: none;
}

/* ---------- ranking card ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 4px 8px;
  margin-bottom: 22px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px 16px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex: none;
}

.card-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
}

.card-subtitle {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.chart-disclaimer {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  line-height: 1.5;
  margin: 0 4px 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.rank-table { table-layout: fixed; }
.rank-table .univ-name { overflow-wrap: break-word; }
.rank-table .col-rank { width: 44px; }
.rank-table .col-score { width: 120px; }
.rank-table .col-apps { width: 105px; }

thead th {
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 18px;
  overflow-wrap: break-word;
}

thead th.num, td.num { text-align: right; }

thead th.sort-active { color: var(--ink); }

tbody tr {
  border-top: 1px solid var(--border);
  transition: background .12s;
}

tbody tr:hover { background: #f8f8fc; }

td {
  padding: 13px 18px;
  vertical-align: middle;
}

.rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eeeef4;
  color: var(--text);
  font-weight: 800;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.univ-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.univ-name {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: break-word;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: var(--radius-pill);
}

.delta.up { color: var(--green); background: rgba(28, 154, 86, 0.12); }
.delta.down { color: var(--red); background: rgba(214, 73, 61, 0.12); }
.delta.flat { color: var(--muted); background: #f1ecec; }
.delta.new { color: var(--accent-dark); background: var(--accent-tint); }

.score {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.applications {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

.show-all {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--accent-dark);
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  padding: 16px 18px;
  cursor: pointer;
  text-align: center;
  margin-top: 6px;
}

.show-all:hover { color: var(--ink); }

/* ---------- side cards ---------- */

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 9px;
}

.legend-row:last-child { margin-bottom: 0; }

/* ---------- methodology / footer / empty ---------- */

.methodology {
  margin: 42px 0 28px;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.methodology-kicker {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.methodology h2 {
  margin: 7px 0 24px;
  font-family: var(--serif);
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.1;
}

.methodology-grid {
  column-gap: 24px;
}

.methodology-grid article {
  min-width: 0;
  break-inside: avoid;
  margin-bottom: 24px;
}
.methodology-grid article:last-child { margin-bottom: 0; }
.methodology-grid h3 { margin: 0 0 9px; font-size: 16px; }
.methodology-grid p { margin: 0 0 10px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.methodology-grid p:last-child { margin-bottom: 0; }
.methodology-grid strong { color: var(--text); }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  padding-top: 10px;
}

.site-footer a { color: var(--ink); font-weight: 700; text-decoration: none; }

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
}

.footer-brand:hover { color: var(--text); }

.footer-logo { height: 30px; width: auto; display: block; }

.empty-state {
  padding: 30px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- university page ---------- */

.uni-wrap { margin-top: 28px; }

.page-nav-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 13.5px;
}

.back-link:hover { color: var(--ink); }

.uni-not-found {
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.uni-not-found a { color: var(--ink); font-weight: 700; text-decoration: none; }

.uni-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.institution-note {
  background: var(--accent-tint);
  border-left: 3px solid var(--accent-dark);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.uni-hero-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  overflow: hidden;
}

.uni-hero-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
}

.uni-hero-eyebrow {
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.uni-hero h1 {
  font-family: var(--sans);
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  line-height: 1.15;
  margin: 0;
}

.uni-stats-row { margin: 22px 0; grid-template-columns: repeat(3, 1fr); }

.uni-analysis {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0 0 22px;
}

.trend-up { color: var(--green); }
.trend-down { color: var(--red); }

.chart-card { padding: 22px 18px 18px; }

.chart-plot { position: relative; }

.chart-wrap { padding: 4px 0 0; }

.chart-dot-hit {
  fill: transparent;
  cursor: pointer;
}

.chart-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -100%) translateY(-10px);
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .1s;
  z-index: 5;
}

.chart-tooltip.visible { opacity: 1; visibility: visible; }

.chart-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
}

.chart-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.chart-svg { width: 100%; height: auto; overflow: visible; }

.chart-baseline { stroke: var(--border); stroke-width: 1; }

.chart-gridline { stroke: var(--border); stroke-width: 1; opacity: 0.5; }

.chart-axis-label-y { font-weight: 500; }

.chart-line {
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-all { stroke: var(--accent-dark); }

.chart-dot-all { fill: var(--accent-dark); }

.chart-axis-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--sans);
  font-weight: 600;
}

.chart-line-compare { stroke: var(--ink-soft); }
.chart-dot-compare { fill: var(--ink-soft); }

.chart-line-compare2 { stroke: var(--green); }
.chart-dot-compare2 { fill: var(--green); }

.chart-bar { rx: 2; }
.chart-bar-all { fill: var(--accent-dark); }
.chart-bar-compare { fill: var(--ink-soft); }
.chart-bar-compare2 { fill: var(--green); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 4px 4px 0;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.chart-legend-swatch {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  flex: none;
}

.chart-legend-swatch.dashed {
  background: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 10px);
}

.compare-block {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px 14px 4px;
  margin-bottom: 22px;
}

.compare-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 14px;
  flex-wrap: wrap;
}

.compare-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.compare-select {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  cursor: pointer;
  max-width: 100%;
}

.add-compare-btn {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px 14px;
  text-decoration: underline;
}

.add-compare-btn:hover { color: var(--accent-dark); }

.compare-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.compare-col {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  min-width: 0;
}

.compare-col-name {
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 10px;
  overflow-wrap: break-word;
}

.compare-col.is-primary .compare-col-name { color: var(--accent-dark); }

.compare-metric {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 5px 0;
  border-top: 1px solid var(--border);
}

.compare-metric:first-of-type { border-top: none; }

.compare-metric span:first-child { color: var(--muted); }
.compare-metric span:last-child { font-weight: 700; }

/* ---------- responsive ---------- */

@media (min-width: 620px) {
  .controls { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .date-chips { min-width: 0; }
  .methodology-grid { columns: 2; }
}

@media (max-width: 480px) {
  table { table-layout: fixed; }
  th, td { padding-left: 10px; padding-right: 10px; }
  .rank-table .col-rank { width: 40px; }
  .rank-table .col-score { width: 70px; }
  .rank-table .col-apps { width: 74px; }
  thead th { padding-left: 4px; padding-right: 4px; font-size: 9.5px; letter-spacing: 0.02em; }
  .univ-cell { gap: 8px; }
  .compare-panel { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .hero { padding-left: 16px; padding-right: 16px; }
  .topbar-inner { padding-left: 16px; padding-right: 16px; }
  th, td { padding-left: 6px; padding-right: 6px; }
  thead th:nth-child(3), td:nth-child(3) { width: 56px; }
  thead th:nth-child(4), td:nth-child(4) { width: 54px; }
}
