:root {
  --bg: #f7f8f5;
  --ink: #18201d;
  --muted: #65716b;
  --line: #dce2dc;
  --panel: #ffffff;
  --green: #19735c;
  --mint: #dff3ea;
  --red: #d34a3a;
  --gold: #d8a31a;
  --cyan: #2a92a8;
  --shadow: 0 18px 45px rgba(24, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  padding: 0 18px;
}

button:hover {
  background: #105844;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 28px;
  justify-content: space-between;
  padding: 32px clamp(18px, 4vw, 56px) 22px;
}

.eyebrow {
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1;
  margin-bottom: 14px;
  max-width: 840px;
}

h2 {
  font-size: 20px;
  margin-bottom: 5px;
}

.lead {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
  margin-bottom: 0;
  max-width: 760px;
}

.country-image {
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: min(230px, 28vw);
  object-fit: cover;
  width: 100%;
}

.dashboard {
  display: grid;
  gap: 18px;
  padding: 0 clamp(18px, 4vw, 56px) 44px;
}

.toolbar,
.api-panel,
.dataset-overview,
.otm-section,
.teachers-section,
.degree-section,
.graduates-section,
.chart-block,
.table-section,
.metadata-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(180px, 1fr) 140px minmax(220px, 1.5fr) auto;
  padding: 16px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

input,
select {
  background: #fff;
  border: 1px solid #cfd8d1;
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 0 12px;
  width: 100%;
}

.api-panel {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr minmax(320px, 560px);
  padding: 16px;
}

.api-panel p,
.section-title p {
  color: var(--muted);
  margin-bottom: 0;
}

#sourceForm {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

.kpi-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 148px;
  padding: 20px;
}

.kpi-card span,
.kpi-card small {
  color: var(--muted);
  display: block;
}

.kpi-card strong {
  display: block;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
  margin: 14px 0 8px;
}

.visual-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}

.chart-block,
.dataset-overview,
.otm-section,
.teachers-section,
.degree-section,
.graduates-section,
.table-section,
.metadata-section {
  min-width: 0;
  padding: 18px;
}

.dataset-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.dataset-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 8px;
  min-height: 130px;
  padding: 14px;
  text-align: left;
}

.dataset-card:hover,
.dataset-card.active {
  background: var(--mint);
  border-color: #9ccdbb;
  color: var(--ink);
}

.dataset-card b {
  line-height: 1.3;
}

.dataset-card span {
  color: var(--muted);
  font-size: 13px;
}

.dataset-card strong {
  font-size: 24px;
  line-height: 1.1;
}

.otm-controls {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.otm-kpis {
  margin-bottom: 18px;
}

.otm-visuals {
  margin-bottom: 18px;
}

.otm-table-wrap {
  max-height: 560px;
}

.otm-section .kpi-card strong,
.teachers-section .kpi-card strong,
.degree-section .kpi-card strong,
.graduates-section .kpi-card strong {
  font-size: clamp(22px, 3vw, 34px);
  overflow-wrap: anywhere;
}

.section-title {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}

#unitBadge {
  background: var(--mint);
  border-radius: 999px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  padding: 7px 12px;
  white-space: nowrap;
}

canvas {
  display: block;
  height: 340px;
  width: 100%;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 520px;
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #eef3ef;
  color: #39443f;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 1;
}

td:nth-child(2) {
  min-width: 260px;
  white-space: normal;
}

.positive {
  color: var(--green);
  font-weight: 800;
}

.negative {
  color: var(--red);
  font-weight: 800;
}

.metadata-section dl {
  display: grid;
  gap: 10px 18px;
  grid-template-columns: minmax(160px, 280px) 1fr;
  margin: 0;
}

.metadata-section dt {
  color: var(--muted);
  font-weight: 800;
}

.metadata-section dd {
  margin: 0;
}

@media (max-width: 1050px) {
  .kpi-grid,
  .visual-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar,
  .otm-controls,
  .api-panel {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar button {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .country-image {
    max-width: 180px;
  }

  .toolbar,
  .api-panel,
  .otm-controls,
  #sourceForm,
  .kpi-grid,
  .visual-grid {
    grid-template-columns: 1fr;
  }

  .toolbar button {
    grid-column: auto;
  }

  .metadata-section dl {
    grid-template-columns: 1fr;
  }

  canvas {
    height: 300px;
  }
}
