:root {
  --navy: #1F4E78;
  --navy-dark: #14344f;
  --blue: #2A78D6;
  --orange: #EB6834;
  --green: #1E8E5A;
  --amber: #C98A00;
  --red: #C4392B;
  --ink: #202733;
  --ink-muted: #5b6472;
  --border: #e2e6ec;
  --surface: #ffffff;
  --surface-alt: #f5f8fb;
  --public-bg: #eaf1fb;
  --private-bg: #fdeee5;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(20, 40, 70, 0.07);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--surface-alt);
  line-height: 1.5;
}

a, button, input, select, .chip, .tab-btn, .kpi, .info-box, .chart-block {
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease,
              transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

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

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- header */
.site-header {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 28px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; }
.brand-text small { color: #cfe0f2; font-size: 11px; }

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  font-size: 18px;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}

.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a {
  color: #e6edf5;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}
.site-nav a:hover { background: rgba(255,255,255,0.12); text-decoration: none; }
.site-nav a.active { background: var(--orange); color: #fff; }

.page-main { padding: 28px 20px 60px; }

/* ----------------------------------------------------------------- hero */
.hero { text-align: center; max-width: 760px; margin: 10px auto 26px; }
.hero h1 { font-size: 28px; color: var(--navy); margin-bottom: 10px; }
.hero p { color: var(--ink-muted); font-size: 15px; }

.page-header { max-width: 820px; margin: 0 auto 22px; }
.page-header h1 { color: var(--navy); font-size: 24px; margin-bottom: 6px; }
.page-header p { color: var(--ink-muted); font-size: 14px; }

/* --------------------------------------------------------------- cards */
.calc-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  max-width: 920px;
  margin: 0 auto 30px;
}

.tab-switch { display: flex; gap: 8px; margin-bottom: 18px; }
.tab-btn {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
}
.tab-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.mode-panel label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink); }
.mode-panel input[type="number"], .mode-panel input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 15px;
}
.marks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 8px; }
.marks-field .weight-tag {
  display: inline-block;
  background: var(--public-bg);
  color: var(--navy);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 700;
}
.obtained-total { display: flex; align-items: center; gap: 8px; }
.obtained-total span { color: var(--ink-muted); }
.live-agg { font-size: 13px; color: var(--ink-muted); margin-top: 4px; }
#livePreviewValue { color: var(--navy); font-size: 15px; }

.filters-row {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin: 20px 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-label { font-weight: 700; font-size: 13px; color: var(--ink-muted); margin-right: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip-disabled { opacity: 0.65; cursor: not-allowed; }
.soon-tag { background: var(--amber); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-left: 4px; }

.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  padding: 13px 26px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn-primary:hover { background: #d95a26; }
.btn-primary:disabled { opacity: 0.7; cursor: progress; }

.btn-secondary {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-link { font-size: 13px; align-self: center; }

/* ------------------------------------------------------------- results */
.results-panel { margin-top: 26px; }
.results-summary { margin-bottom: 14px; font-size: 14px; }
.agg-pill { background: var(--navy); color: #fff; padding: 3px 10px; border-radius: 14px; font-size: 14px; }

.tier-block { margin-bottom: 24px; }
.tier-heading { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 8px; }
.tier-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tier-strong .tier-dot { background: var(--green); }
.tier-eligible .tier-dot { background: var(--blue); }
.tier-borderline .tier-dot { background: var(--amber); }
.tier-unlikely .tier-dot { background: var(--red); }
.tier-count { color: var(--ink-muted); font-weight: 400; font-size: 13px; }

.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--navy); color: #fff; font-weight: 600; position: sticky; top: 0; }
tbody tr:nth-child(even) { background: var(--surface-alt); }
tbody tr:hover { background: #eef4fb; }
td:first-child, th:first-child { white-space: normal; min-width: 200px; }

.badge { padding: 2px 9px; border-radius: 12px; font-size: 11.5px; font-weight: 700; }
.badge-public { background: var(--public-bg); color: var(--navy); }
.badge-private { background: var(--private-bg); color: var(--orange); }
.badge-quota { background: #eef0f2; color: #444; }

.margin-pos { color: var(--green); font-weight: 700; }
.margin-neg { color: var(--red); font-weight: 700; }

.notice { padding: 12px 16px; border-radius: 8px; background: var(--surface-alt); font-size: 14px; }
.notice-error { background: #fbe9e7; color: var(--red); }
.notice-muted { color: var(--ink-muted); font-size: 13px; background: transparent; padding-left: 0; }

.disclaimer-line {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 14px;
  background: #fff4ec;
  border: 1px solid #f6d9c4;
  border-radius: 8px;
  color: #8a4a1f;
  font-size: 12.5px;
  max-width: 720px;
}

/* --------------------------------------------------------------- info */
.info-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; max-width: 920px; margin: 0 auto; }
.info-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; text-align: center; }
.info-box h3 { color: var(--navy); font-size: 22px; margin: 0 0 4px; }
.info-box p { color: var(--ink-muted); font-size: 13px; margin: 0; }

/* ------------------------------------------------------------- filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: #fff;
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.filter-bar select, .filter-bar input.search-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
}
.search-input { min-width: 220px; flex: 1; }
.result-count { font-size: 13px; color: var(--ink-muted); margin: 0 0 10px; }
.highlight-row { background: #fff8e1 !important; }
.empty-row { text-align: center; color: var(--ink-muted); padding: 24px; }

.pagination { display: flex; gap: 14px; align-items: center; justify-content: center; margin-top: 18px; font-size: 14px; }
.page-status { color: var(--ink-muted); }

/* ------------------------------------------------------------- compare */
.kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 26px; }
.kpi { border-radius: var(--radius); padding: 16px; text-align: center; color: #fff; }
.kpi.public { background: linear-gradient(135deg, var(--navy), var(--blue)); }
.kpi.private { background: linear-gradient(135deg, #8a3d1a, var(--orange)); }
.kpi h3 { margin: 0 0 4px; font-size: 20px; }
.kpi p { margin: 0; font-size: 11.5px; opacity: 0.9; }

.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px; }
.col-heading { font-size: 16px; padding: 8px 14px; border-radius: 8px 8px 0 0; margin: 0; }
.public-heading { background: var(--public-bg); color: var(--navy); }
.private-heading { background: var(--private-bg); color: var(--orange); }

.ranking-section h2 { color: var(--navy); font-size: 19px; }
.ranking-section p { color: var(--ink-muted); font-size: 13.5px; }

/* --------------------------------------------------------------- charts */
.chart-block { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 22px; }
.chart-block h2 { margin-top: 0; font-size: 16px; color: var(--navy); }
.chart-wrap { position: relative; height: 420px; }
.chart-wrap.chart-tall { height: 620px; }
.chart-count { color: var(--ink-muted); font-size: 12.5px; font-weight: 400; }

/* --------------------------------------------- simple dependency-free bar charts */
.bar-chart-legend { display: flex; gap: 18px; margin-bottom: 14px; font-size: 12.5px; color: var(--ink-muted); flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-top { background: var(--blue); }
.legend-closing { background: var(--navy); }
.legend-public { background: var(--blue); }
.legend-private { background: var(--orange); }

.bar-chart-list { display: flex; flex-direction: column; gap: 18px; max-height: 640px; overflow-y: auto; padding-right: 4px; }
.bar-chart-list-single { gap: 10px; }

.bar-group { border-bottom: 1px solid var(--border, #e6ecf3); padding-bottom: 12px; }
.bar-group:last-child { border-bottom: none; padding-bottom: 0; }
.bar-group-single { display: flex; align-items: center; gap: 10px; border-bottom: none; padding-bottom: 0; }
.bar-group-single .bar-group-label { flex: 0 0 260px; }
.bar-group-single .bar-row { flex: 1; margin-top: 0; }

.bar-group-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.bar-group-city { font-weight: 400; color: var(--ink-muted); font-size: 11.5px; margin-left: 8px; }

.bar-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.bar-row-tag { flex: 0 0 42px; font-size: 10.5px; font-weight: 700; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .03em; }

.bar-track {
  flex: 1;
  background: #eef2f7;
  border-radius: 5px;
  height: 22px;
  overflow: hidden;
  min-width: 0;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  min-width: 34px;
  box-sizing: border-box;
  transition: width .3s ease;
}
.bar-fill-value { color: #fff; font-size: 11px; font-weight: 700; white-space: nowrap; }

.bar-top { background: var(--blue); }
.bar-closing { background: var(--navy); }
.bar-seats, .bar-seats-public { background: var(--blue); }
.bar-seats-private { background: var(--orange); }
.bar-sector-public { background: var(--blue); }
.bar-sector-private { background: var(--orange); }

@media (max-width: 640px) {
  .bar-group-label { font-size: 12px; }
  .bar-row-tag { flex-basis: 36px; font-size: 9.5px; }
  .bar-group-single .bar-group-label { flex-basis: 150px; }
}

/* ---------------------------------------------------------------- prose */
.prose { max-width: 820px; margin: 0 auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 32px; }
.prose h2 { color: var(--navy); font-size: 18px; margin-top: 26px; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { font-size: 14.5px; color: var(--ink); }
.prose code { background: var(--surface-alt); padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* ---------------------------------------------------------------- footer */
.site-footer { background: var(--navy-dark); color: #cfe0f2; padding: 22px 0; margin-top: 40px; }
.footer-inner p { font-size: 12.5px; margin: 0 0 6px; }
.footer-meta { color: #9db6cd; }
.footer-inner a { color: #fff; text-decoration: underline; }

/* -------------------------------------------------------------- mobile */
@media (max-width: 760px) {
  .nav-toggle { display: inline-block; }
  .site-nav { display: none; width: 100%; flex-direction: column; margin-top: 10px; }
  .site-nav.open { display: flex; }
  .side-by-side { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .calc-card { padding: 18px; }
  .hero h1 { font-size: 22px; }
}

@media print {
  .site-header, .site-footer, .filter-bar, .btn-primary, .nav-toggle, .back-to-top { display: none !important; }
}

/* ------------------------------------------------------- mobile nav polish */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 35, 0.45);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.nav-backdrop.open { display: block; opacity: 1; }

@media (max-width: 760px) {
  .site-nav {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: min(78vw, 300px);
    background: var(--navy-dark);
    z-index: 45;
    padding: 70px 18px 18px;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -6px 0 24px rgba(0,0,0,0.25);
  }
  .site-nav.open { transform: translateX(0); display: flex; }
  .site-nav a { padding: 12px 14px; border-radius: 8px; }
}

/* ------------------------------------------------------------ hover lifts */
.info-box:hover, .kpi:hover, .chart-block:hover, .calc-card:hover { box-shadow: 0 8px 22px rgba(20,40,70,0.13); transform: translateY(-2px); }
.chip:hover:not(.chip-disabled) { border-color: var(--blue); background: var(--public-bg); }
.chip:has(input:checked) { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip:has(input:checked) .soon-tag { background: #fff; color: var(--amber); }
.tab-btn:hover:not(.active) { background: #e9eef4; }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(235,104,52,0.35); }
.btn-secondary:hover { background: var(--navy-dark); }
tbody tr { transition: background-color 0.12s ease; }

/* ------------------------------------------------------------- animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.tier-block { animation: fadeInUp 0.35s ease both; }
.tier-block:nth-child(2) { animation-delay: 0.05s; }
.tier-block:nth-child(3) { animation-delay: 0.1s; }
.tier-block:nth-child(4) { animation-delay: 0.15s; }
.results-summary { animation: fadeInUp 0.3s ease both; }

.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s ease, transform 0.5s ease; }
.reveal.revealed { opacity: 1; transform: translateY(0); }

/* ------------------------------------------------------------ back-to-top */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--navy);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  z-index: 30;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.back-to-top:hover { background: var(--orange); }

/* -------------------------------------------------------- responsive fine-tuning */
@media (max-width: 640px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select, .filter-bar input.search-input, .filter-bar .btn-secondary, .filter-bar .btn-link { width: 100%; }
  .marks-grid { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  th, td { padding: 8px 9px; font-size: 12.5px; }
  .hero p { font-size: 14px; }
}

@media (max-width: 420px) {
  .kpi-strip { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------- session badge */
.session-badge {
  display: inline-block;
  background: var(--public-bg);
  color: var(--navy);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 12px;
}
.session-badge-inline {
  margin-bottom: 0;
  vertical-align: middle;
  font-size: 11.5px;
  padding: 3px 10px;
}
.session-callout {
  max-width: 820px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: #fff;
  padding: 16px 22px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow);
}

.field-hint { margin: 4px 0 0; font-size: 11.5px; color: var(--ink-muted); }

.public-only-tag {
  background: var(--public-bg);
  color: var(--navy);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  font-weight: 700;
}
.chip:has(input:checked) .public-only-tag { background: #fff; color: var(--navy); }

/* ------------------------------------------------------- program switcher */
.program-switcher {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.prog-tab {
  background: #fff;
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-muted);
}
.prog-tab:hover { border-color: var(--blue); text-decoration: none; }
.prog-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.prog-tab-note {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--amber);
  color: #fff;
}
.prog-tab.active .prog-tab-note { background: #fff; color: var(--amber); }
