:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --ink: #1b1f2a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4338ca;
  --brand-ink: #ffffff;
  --brand-soft: #eef0fd;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.brand h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 19px;
  line-height: 1.2;
}

.brand-sub {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.tabs {
  display: flex;
  background: var(--bg);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab.active {
  background: var(--brand);
  color: #fff;
}

.tab-count {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

.tab:not(.active) .tab-count {
  background: var(--line);
  color: var(--ink);
}

/* ---------- Layout ---------- */

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
}

#view-search {
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

#view-prefs {
  grid-template-columns: 1fr;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel h2 {
  margin: 0;
  font-size: 16px;
}

/* ---------- Filters ---------- */

.filters {
  position: sticky;
  top: 82px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.link-btn {
  border: none;
  background: none;
  color: var(--brand);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-sep {
  color: var(--muted);
}

.segmented {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: var(--card);
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

/* ---------- Combobox ---------- */

.combo {
  position: relative;
}

.combo-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  display: none;
}

.combo-field.has-value .combo-clear {
  display: block;
}

.combo-field.has-value .combo-input {
  padding-right: 28px;
  font-weight: 700;
  color: var(--brand);
}

.combo-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
  display: none;
}

.combo.open .combo-list {
  display: block;
}

.combo-option {
  padding: 8px 11px;
  font-size: 13.5px;
  cursor: pointer;
}

.combo-option:hover,
.combo-option.highlight {
  background: var(--brand-soft);
}

.combo-empty {
  padding: 10px 11px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Results ---------- */

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

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

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 15px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
}

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

.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--brand);
  color: #fff;
}

.btn.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.btn.small {
  padding: 7px 12px;
  font-size: 12.5px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  border-color: #cfd4ff;
  box-shadow: 0 4px 16px rgba(67, 56, 202, 0.08);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-university {
  font-weight: 800;
  font-size: 14px;
  line-height: 1.3;
}

.card-department {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 15.5px;
  color: var(--brand);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.devlet {
  background: #e0f2fe;
  color: #075985;
}

.badge.vakif {
  background: #ede9fe;
  color: #5b21b6;
}

.badge.score-type {
  background: var(--brand-soft);
  color: var(--brand);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--muted);
}

.card-stats {
  display: flex;
  gap: 18px;
  margin-top: 2px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-value {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 15px;
}

.stat.current .stat-value {
  color: var(--brand);
  font-size: 17px;
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  gap: 8px;
}

.source-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

.source-link:hover {
  color: var(--brand);
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ---------- Preferences ---------- */

.prefs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pref-row {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.pref-order {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
  font-family: "Space Grotesk", sans-serif;
  display: grid;
  place-items: center;
  font-size: 13px;
}

.pref-info .pref-title {
  font-weight: 800;
  font-size: 13.5px;
}

.pref-info .pref-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.pref-note {
  width: 200px;
}

.pref-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  display: grid;
  place-items: center;
  font-family: inherit;
}

.icon-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.icon-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

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

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  #view-search {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
    max-height: none;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .pref-row {
    grid-template-columns: 28px 1fr;
    grid-template-areas:
      "order info"
      "note note"
      "actions actions";
  }

  .pref-order {
    grid-area: order;
  }

  .pref-info {
    grid-area: info;
  }

  .pref-note {
    grid-area: note;
    width: 100%;
  }

  .pref-actions {
    grid-area: actions;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .topbar-inner {
    padding: 12px 16px;
  }

  .container {
    padding: 14px;
  }
}
