/* compare page — tokens from styles.css :root */
/* styles.css sets overflow-x:hidden on html/body; that creates a
   non-scrolling overflow box and kills thead { position:sticky; top:0 }. */

html.table-html,
html.table-html body.table-page {
  overflow-x: clip;
  overflow-y: visible;
}

.table-page {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  margin: 0;
  padding: 0;
}

.table-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 20px;
  padding: 10px 16px 4px;
  max-width: 100%;
}

.table-back {
  flex: 0 0 auto;
  min-height: 40px;
}

.table-head__text {
  flex: 1 1 16rem;
  min-width: 0;
}

.table-kicker {
  margin: 0 0 2px;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--font-mono);
}

.table-head h1 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.table-lead {
  margin: 0;
  max-width: 52em;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.4;
}

.table-lead strong { color: var(--text); font-weight: 650; }

.table-toolbar {
  padding: 6px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.table-search label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.table-search input {
  width: min(100%, 22rem);
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
}

.table-search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip-set {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chip-set legend {
  float: left;
  width: auto;
  margin: 0 8px 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 3.5rem;
}

.chip-set label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.chip-set label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(232, 163, 61, .12);
}

.chip-set--flags label:has(input:checked) {
  background: rgba(79, 168, 184, .14);
  border-color: var(--b);
}

.chip-set input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.table-count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.table-wrap {
  max-width: 100%;
  margin: 0;
  padding: 0 16px;
  border-top: 1px solid var(--line);
}

.table-hint {
  margin: 0;
  padding: 10px 16px 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.cmp {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: 100%;
  font-size: 13px;
}

.col-school { width: 16%; }
.col-prog { width: 20%; }
.col-form { width: 9%; }
.col-price { width: 9%; }
.col-budget { width: 7%; }
.col-ege { width: 6%; }
.col-exams { width: 16%; }
.col-work { width: 8%; }
.col-status { width: 9%; }

.cmp th,
.cmp td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  background: var(--bg);
  overflow-wrap: anywhere;
}

.cmp thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-deep);
  font-weight: 600;
  box-shadow: 0 1px 0 var(--line-strong);
}

.cmp thead th:nth-child(1),
.cmp tbody td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg);
}

.cmp thead th:nth-child(1) {
  z-index: 6;
  top: 0;
  background: var(--bg-deep);
}

.cmp th button {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
}

.cmp th button::after {
  content: "↕";
  font-size: 10px;
  opacity: .35;
  font-family: var(--font-mono);
}

.cmp th[aria-sort="ascending"] button::after,
.cmp th button.is-sorted[data-dir="asc"]::after { content: "↑"; opacity: 1; color: var(--accent); }
.cmp th[aria-sort="descending"] button::after,
.cmp th button.is-sorted[data-dir="desc"]::after { content: "↓"; opacity: 1; color: var(--accent); }

.cmp th button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cmp tbody tr.cmp-row { cursor: pointer; }
.cmp tbody tr.cmp-row:hover td { background: var(--surface); }
.cmp tbody tr.cmp-row:hover td:nth-child(1) { background: var(--surface); }
.cmp tbody tr.cmp-row.is-open td { background: var(--surface-2); }
.cmp tbody tr.cmp-row.is-open td:nth-child(1) { background: var(--surface-2); }

.cmp tbody tr.status-recommend td:nth-child(1) { box-shadow: inset 3px 0 0 var(--accent); }
.cmp tbody tr.status-reserve td:nth-child(1) { box-shadow: inset 3px 0 0 var(--text-muted); }
.cmp tbody tr.status-nosuit td:nth-child(1) { box-shadow: inset 3px 0 0 #8a4a4a; }

.school-name { font-weight: 650; display: block; line-height: 1.25; }
.school-meta,
.prog-doc,
.housing-warn {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}
.housing-warn { color: var(--accent-soft); }
.prog-doc { color: var(--text-2); }

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.muted { color: var(--text-muted); }

.price {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 13px;
}
.price--ok { color: #7FB069; }
.price--mid { color: var(--accent-soft); }
.price--over { color: #E2795F; }

.form-cell, .ege-cell, .budget-cell, .work-cell {
  overflow-wrap: normal;
  white-space: nowrap;
  font-size: 12px;
}

.work-cell { color: var(--text-2); }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}
.badge--rec { background: rgba(232,163,61,.18); color: var(--accent-soft); }
.badge--res { background: rgba(148,142,128,.16); color: var(--text-2); }
.badge--no { background: rgba(226,121,95,.16); color: #E2795F; }

.cmp-detail td {
  background: var(--bg-deep) !important;
  padding: 0;
  border-bottom: 1px solid var(--line-strong);
}

.detail {
  padding: 14px 16px 18px 16px;
  display: grid;
  gap: 12px;
}

.prog-card .detail {
  padding: 12px 0 0;
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.detail-about {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

.detail-quality {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.detail-quality__label {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--font-mono);
}

.detail-link {
  margin: 0;
  font-size: 14px;
}

.detail dl {
  margin: 0;
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 6px 12px;
  font-size: 14px;
}

.detail dt { color: var(--text-muted); }
.detail dd { margin: 0; color: var(--text); }

.detail a { color: var(--accent); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.table-sort-mobile { display: none; }
.cmp-cards { display: none; }

@media (min-width: 960px) {
  .filters-fold {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 0;
    padding: 0;
    background: transparent;
  }
  .filters-fold > summary {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

.filters-fold > summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 650;
  font-size: 15px;
  list-style: none;
}
.filters-fold > summary::-webkit-details-marker { display: none; }
.filters-fold > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--accent);
  font-size: 12px;
}
.filters-fold[open] > summary::after { content: "▴"; }

.table-sort-mobile label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.table-sort-mobile select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

.prog-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px 14px;
  cursor: pointer;
  box-shadow: inset 3px 0 0 transparent;
}

.prog-card.status-recommend { box-shadow: inset 3px 0 0 var(--accent); }
.prog-card.status-reserve { box-shadow: inset 3px 0 0 var(--text-muted); }
.prog-card.status-nosuit { box-shadow: inset 3px 0 0 #8a4a4a; }
.prog-card.is-open { background: var(--surface-2); }

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

.prog-card__top .school-name { margin-right: auto; min-width: 0; }
.prog-card__top .badge { flex-shrink: 0; }
.prog-card__name {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 600;
}

.card-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.card-facts li {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.card-facts .k {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.card-exams {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-2);
}

.cards-empty {
  margin: 0;
  padding: 16px;
  color: var(--text-muted);
}

@media (max-width: 959px) {
  .table-head { padding: 12px 12px 6px; }
  .table-toolbar { padding: 8px 12px 10px; }
  .table-search input { width: 100%; font-size: 16px; }
  .chip-set label { min-height: 40px; }
  .table-sort-mobile { display: block; }
  .filters-fold {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 0 12px 8px;
    background: var(--surface);
  }
  .filters-fold > summary { margin: 0 -12px; padding: 0 12px; }
  .filters-fold[open] > summary {
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }
  .table-wrap { display: none; }
  .cmp-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 12px 8px;
  }
  .table-hint { padding: 8px 12px 24px; }
  .detail dl { grid-template-columns: 6.5rem 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .cmp tbody tr.cmp-row { transition: none; }
}
