/* OTM Mandat — Telegram Mini App UI */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

:root {
  --tg-theme-bg-color: #f1f5f9;
  --tg-theme-text-color: #1e293b;
  --tg-theme-hint-color: #64748b;
  --tg-theme-link-color: #0284c7;
  --tg-theme-button-color: #0284c7;
  --tg-theme-button-text-color: #ffffff;
  --tg-theme-secondary-bg-color: #ffffff;

  --bg: #f1f5f9;
  --bg-elevated: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: var(--tg-theme-button-color, #0284c7);
  --primary-dark: #0369a1;
  --primary-light: #38bdf8;
  --primary-soft: #e0f2fe;
  --accent: #22d3ee;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --input-bg: #f8fafc;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 32px rgba(2, 132, 199, 0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --header-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  color-scheme: light;
}

html[data-theme="light"] {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Yorug' fon — yumshoq ko'k gradient */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, #f0f9ff 0%, #f1f5f9 35%, #f8fafc 100%),
    radial-gradient(ellipse 90% 60% at 50% -30%, rgba(56, 189, 248, 0.2), transparent),
    radial-gradient(ellipse 50% 40% at 100% 20%, rgba(34, 211, 238, 0.08), transparent);
  pointer-events: none;
  z-index: -1;
}

a {
  color: var(--tg-theme-link-color, #0369a1);
}

/* ——— Header ——— */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.nav a:hover,
.nav a:focus-visible {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ——— Layout ——— */
.main {
  padding: 20px 16px calc(88px + var(--safe-bottom));
  max-width: 640px;
  margin: 0 auto;
}

.footer {
  text-align: center;
  padding: 8px 16px calc(72px + var(--safe-bottom));
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ——— Menyu o'tish indikatori ——— */
.nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 300;
  pointer-events: none;
  overflow: hidden;
}

.nav-progress::after {
  content: "";
  display: block;
  height: 100%;
  width: 28%;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
  transform: translateX(-120%);
  opacity: 0;
  transition: opacity 0.15s;
}

body.nav-loading .nav-progress::after {
  opacity: 1;
  animation: nav-progress-slide 0.85s ease-in-out infinite;
}

@keyframes nav-progress-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(420%);
  }
}

/* ——— Pastki menyu ——— */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 16px rgba(15, 23, 42, 0.06);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: var(--radius-xs);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: color var(--transition), background var(--transition);
}

.bottom-nav-item > span:last-child {
  max-width: 100%;
  word-break: break-word;
}

.bottom-nav-item:hover,
.bottom-nav-item:focus-visible,
.bottom-nav-item.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.bottom-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.bottom-nav-item--main {
  margin-top: -14px;
  color: var(--primary);
}

.bottom-nav-item--main .bottom-nav-icon--main {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 2px;
  border-radius: 50%;
  font-size: 1.5rem;
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.35);
  border: 3px solid #fff;
}

.bottom-nav-item--main:hover .bottom-nav-icon--main,
.bottom-nav-item--main:focus-visible .bottom-nav-icon--main,
.bottom-nav-item--main.is-active .bottom-nav-icon--main {
  box-shadow: 0 6px 18px rgba(12, 74, 110, 0.45);
}

.bottom-nav-item--main.is-active {
  background: transparent;
}

.bottom-nav-item--main.is-active > span:last-child {
  font-weight: 700;
}

.calc-top {
  margin-bottom: 16px;
}

.fieldset-optional {
  border-style: dashed;
}

.optional-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.check-row input {
  width: auto;
  margin: 0;
}

.subject-block .cert-fields,
.subject-block .test-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.subject-block .cert-fields[hidden],
.subject-block .test-fields[hidden] {
  display: none !important;
}

.mand-block {
  padding: 12px;
  background: var(--input-bg);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.mand-block .mand-test-fields[hidden] {
  display: none !important;
}

.results-toolbar {
  margin: 12px 0;
  align-items: center;
}

.results-toolbar .hint-small {
  flex: 1;
  text-align: right;
  margin: 0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
}

.pagination-btn {
  padding: 10px 18px;
  border-radius: var(--radius-xs);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), transform var(--transition);
}

.pagination-btn:hover {
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.pagination-info {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 4rem;
  text-align: center;
}

/* ——— Page header ——— */
.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.page-header .hint {
  margin: 0;
}

.hero {
  margin-bottom: 24px;
  padding: 24px 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 45%, #38bdf8 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 60%;
  height: 120%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  position: relative;
}

.hero p {
  margin: 0;
  font-size: 14px;
  opacity: 0.92;
  line-height: 1.5;
  position: relative;
}

.hint {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.hint-small {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

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

/* ——— Cards ——— */
.cards {
  display: grid;
  gap: 12px;
}

.card {
  display: block;
  padding: 18px 18px 18px 56px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--border);
  border-radius: 4px 0 0 4px;
  transition: background var(--transition);
}

.card:hover,
.card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--primary-light) 40%, var(--border));
}

.card:hover::before {
  background: linear-gradient(180deg, var(--primary-light), var(--accent));
}

.card-primary {
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
  background: linear-gradient(135deg, var(--card) 0%, var(--primary-soft) 120%);
}

.card-primary::before {
  background: linear-gradient(180deg, var(--primary), var(--primary-light));
}

.card-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.35rem;
  line-height: 1;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ——— Forms ——— */
.form-panel,
.search-form,
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  margin-bottom: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.filter-bar {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-bar label {
  flex: 1;
  min-width: 140px;
}

.form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  padding: 16px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.form legend {
  font-weight: 700;
  font-size: 13px;
  padding: 0 6px;
  color: var(--primary);
  letter-spacing: 0.01em;
}

.form label,
.search-form label,
.filter-bar label {
  display: block;
  margin-bottom: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.form input,
.form select,
.search-form input,
.search-form select,
.filter-bar input,
.filter-bar select {
  width: 100%;
  padding: 12px 14px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--input-bg);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
}

.form input:focus,
.form select:focus,
.search-form input:focus,
.search-form select:focus,
.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-light) 25%, transparent);
}

.form select,
.search-form select,
.filter-bar select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.grid-3 {
  display: grid;
  gap: 12px;
}

@media (min-width: 520px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .filter-bar {
    flex-wrap: nowrap;
  }
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 40%, transparent);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ——— Results / scores ——— */
.results-header {
  padding: 20px;
  margin-bottom: 16px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.results-header h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 700;
}

.score-big {
  display: inline-block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.breakdown,
.summary {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 0;
}

.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.stat-chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.stat-chip-grant {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.stat-chip-contract {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.form-cell {
  white-space: nowrap;
}

.form-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--primary-soft, #e8f4fc);
  color: var(--primary, #0369a1);
}

.form-chip-kechki {
  background: #fef3c7;
  color: #92400e;
}

.form-chip-masofaviy {
  background: #e0e7ff;
  color: #3730a3;
}

.form-chip-sirtqi {
  background: #f3e8ff;
  color: #6b21a8;
}

.lang-hint {
  color: var(--text-muted, #64748b);
  font-size: 10px;
}

.filter-bar--lowest {
  flex-wrap: wrap;
  gap: 10px 14px;
}

.browse-results-meta {
  margin: 8px 0 4px;
  color: var(--text-muted, #64748b);
  font-size: 13px;
}

.data-table--lowest .rank-cell {
  width: 2rem;
  text-align: center;
  color: var(--text-muted, #64748b);
  font-weight: 600;
}

.score-low {
  color: #047857;
  font-size: 1.05rem;
}

/* ——— Tables ——— */
.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--card);
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--primary-soft) 40%, transparent);
}

.data-table td strong {
  font-weight: 600;
  color: var(--text);
}

.data-table small {
  color: var(--text-muted);
  font-size: 11px;
}

.chance-grant {
  background: color-mix(in srgb, #ecfdf5 60%, var(--card));
}

.chance-contract {
  background: color-mix(in srgb, #eff6ff 60%, var(--card));
}

.chance-low {
  background: color-mix(in srgb, #fefce8 50%, var(--card));
}

.chance-impossible {
  background: color-mix(in srgb, #fef2f2 50%, var(--card));
}

/* ——— Badges ——— */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-grant {
  background: #d1fae5;
  color: #065f46;
}

.badge-contract {
  background: #dbeafe;
  color: #1e40af;
}

.badge-low {
  background: #fef3c7;
  color: #92400e;
}

.badge-impossible {
  background: #fee2e2;
  color: #991b1b;
}

.badge-warn {
  background: #ffedd5;
  color: #9a3412;
}

/* ——— Alerts ——— */
.alert {
  padding: 20px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.alert h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.alert-warn,
.alert.alert-warn {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fde68a;
}

.alert-error {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border-color: #fecaca;
}

/* ——— Yo'nalish qidiruv (takliflar) ——— */
.search-form--directions {
  flex-direction: column;
  align-items: stretch;
}

.search-field-wrap {
  position: relative;
  width: 100%;
}

.dir-suggestions {
  margin-top: 6px;
}

.suggest-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
}

.suggest-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: background var(--transition);
}

.suggest-list li:last-child .suggest-item {
  border-bottom: none;
}

.suggest-item:hover,
.suggest-item:focus-visible {
  background: var(--primary-soft);
  outline: none;
}

.suggest-item-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.suggest-item-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.suggest-hint,
.suggest-empty {
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--card);
  border-radius: var(--radius-xs);
  border: 1px dashed var(--border);
}

.selected-direction {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--primary-soft);
  border-radius: var(--radius-xs);
  border: 1px solid color-mix(in srgb, var(--primary-light) 35%, var(--border));
  font-size: 14px;
}

.selected-direction-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.selected-direction strong {
  font-weight: 700;
  color: var(--primary);
  line-height: 1.35;
}

.dir-results-block {
  margin-top: 16px;
}

.match-row-hint {
  margin: 0 0 8px;
}

.match-row {
  cursor: pointer;
  transition: background var(--transition);
}

.match-row:hover,
.match-row:focus-visible {
  background: var(--primary-soft);
  outline: none;
}

.match-detail {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.match-detail-row {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 8px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.match-detail-row:last-child {
  border-bottom: none;
}

.match-detail-row dt {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.match-detail-row dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.match-detail-row--highlight dd .score-big {
  font-size: 22px;
  color: var(--primary);
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--transition), visibility var(--transition);
}

.modal.is-open {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  max-height: min(88vh, 720px);
  margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal.is-open .modal-panel {
  transform: translateY(0);
}

#dir-modal-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(88vh, 720px);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header-text {
  min-width: 0;
  flex: 1;
}

.modal-eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  word-break: break-word;
}

.modal-sub {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.modal-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.modal-close:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.modal-body {
  padding: 0 16px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-body .table-wrap {
  margin-top: 8px;
}

@media (min-width: 520px) {
  .modal {
    align-items: center;
    padding: 16px;
  }

  .modal-panel {
    border-radius: var(--radius);
    max-height: min(85vh, 680px);
    transform: translateY(16px) scale(0.96);
    opacity: 0;
  }

  .modal.is-open .modal-panel {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ——— University list ——— */
.uni-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.uni-list a {
  display: block;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.uni-list a:hover {
  transform: translateX(4px);
  border-color: color-mix(in srgb, var(--primary-light) 50%, var(--border));
  box-shadow: var(--shadow-md);
}

.uni-list strong {
  display: block;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  line-height: 1.35;
}

.uni-list span {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.uni-list small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 32px 16px;
  font-size: 14px;
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}

/* ——— HTMX loading ——— */
.htmx-indicator {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 16px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
}

.htmx-indicator::before {
  content: "";
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: flex;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ——— Misc ——— */
#sub-results,
#results,
#dir-results,
#dir-suggestions,
#uni-list {
  min-height: 48px;
}

input[type="search"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.1a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
  padding-left: 42px !important;
}

input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
  accent-color: var(--primary);
}

fieldset .grid-3 > div {
  padding: 12px;
  background: var(--input-bg);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

fieldset .grid-3 strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

code {
  font-size: 12px;
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
