:root {
  color-scheme: light;
  --paper: #edf3fb;
  --surface: #fff;
  --ink: #142949;
  --text: #2a415e;
  --muted: #4e637d;
  --line: #d4e0ef;
  --navy: #102b54;
  --male-light: #a5ceff;
  --female-light: #83e2c3;
  --male-fill: #4476cf;
  --female-fill: #158673;
  --radius: 15px;
  --shadow: 0 3px 12px rgba(25, 54, 97, .05);
}

:root, .palette-teal {
  --theme-accent: #086455;
  --theme-soft: #e0f3ec;
  --theme-wash: #f2faf7;
  --theme-border: #c9e4da;
  --theme-control: #6b9087;
  --bar-start: #097768;
  --bar-end: #178c79;
}

.palette-blue {
  --theme-accent: #244f9f;
  --theme-soft: #e5efff;
  --theme-wash: #f3f7ff;
  --theme-border: #ccddf5;
  --theme-control: #7891b4;
  --bar-start: #345fbb;
  --bar-end: #4879d0;
}

.palette-violet {
  --theme-accent: #613886;
  --theme-soft: #efe5fa;
  --theme-wash: #fbf7ff;
  --theme-border: #e4d5f0;
  --theme-control: #947faa;
  --bar-start: #7246a6;
  --bar-end: #885bb7;
}

.palette-gold {
  --theme-accent: #81450c;
  --theme-soft: #ffeed4;
  --theme-wash: #fffaf1;
  --theme-border: #ecd7b5;
  --theme-control: #9c8665;
  --bar-start: #a35c13;
  --bar-end: #ba721d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.55 Inter, system-ui, sans-serif;
}

main { flex: 1; }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.18; }
a { color: var(--theme-accent); text-underline-offset: .2em; }
button, input, select { font: inherit; }
a, button:not([disabled]), select, summary { cursor: pointer; }

:focus-visible {
  outline: 3px solid #285cb7;
  outline-offset: 4px;
}

.sr-only,
.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  z-index: 5;
  top: 1rem;
  left: 1rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border-radius: 8px;
  font-weight: 700;
}

.wrap {
  width: min(1184px, calc(100% - 3rem));
  margin-inline: auto;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-header::before {
  content: '';
  display: block;
  height: 4px;
  background: linear-gradient(90deg, #1e509e 0%, #376cc3 43%, #19877e 81%, #d39439 100%);
}

.masthead, .footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.masthead { min-height: 66px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.18;
}

.brand img { width: auto; height: 38px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.02rem; }
.brand small { margin-top: .18rem; color: var(--muted); font-size: .76rem; }

.back-link, .text-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 44px;
  font-size: .88rem;
  font-weight: 680;
}

.back-link { color: var(--ink); text-decoration: none; }
.back-link:hover { color: var(--theme-accent); text-decoration: underline; }
.text-link:hover { color: var(--ink); }

.intro-band {
  background: linear-gradient(102deg, #e0ebff 0%, #edf5ff 53%, #def4ee 100%);
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1.5rem 2rem;
  padding-block: 2.5rem 1.9rem;
}

.page-heading h1 {
  font-size: clamp(2.05rem, 4.25vw, 3.45rem);
  letter-spacing: -.055em;
  font-weight: 760;
  text-wrap: balance;
}

.page-heading h1 + p {
  margin-top: .55rem;
  color: var(--muted);
  font-size: 1.02rem;
}

.edition {
  padding: .15rem 0 .15rem 1.15rem;
  border-left: 3px solid #3b8da1;
  flex: 0 0 min(19rem, 42%);
  max-width: 100%;
}

.edition-label { display: block; font-size: .8rem; font-weight: 680; color: var(--text); }

.edition-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: .75rem;
}

.edition-select {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: .3rem;
  padding: .45rem .7rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #718baf;
  border-radius: 8px;
  font-weight: 700;
}

.edition-select:disabled { color: var(--muted); opacity: 1; cursor: wait; }
.edition-time, .edition-feedback { font-size: .78rem; color: var(--muted); }
.edition-time, .edition-feedback:not(:empty) { margin-top: .35rem; }

.notice {
  padding: .9rem 1rem;
  margin-bottom: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.topics {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-block: 1px solid var(--line);
}

.topic-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 clamp(.5rem, 3vw, 1.85rem);
}

.topic-links a {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: .6rem .3rem .45rem;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: .91rem;
  font-weight: 650;
  text-decoration: none;
}

.topic-links a:hover,
.topic-links a[aria-current] {
  color: var(--theme-accent);
  background: var(--theme-wash);
}
.topic-links a:focus-visible { outline-offset: -4px; }
.topic-links a[aria-current] { border-bottom-color: var(--theme-accent); }

.views { padding-block: 1.6rem 3rem; }
.view { scroll-margin-top: 4.5rem; }

.view-title {
  margin-bottom: 1rem;
  color: var(--theme-accent);
  font-size: clamp(1.48rem, 3vw, 2rem);
  letter-spacing: -.035em;
}

.overview-grid, .overview-secondary, .profile-grid, .jobs-grid {
  display: grid;
  gap: 1rem;
}

.overview-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 8fr); }
.overview-secondary { grid-template-columns: minmax(0, 8fr) minmax(0, 5fr); margin-top: 1rem; }
.profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.jobs-grid { grid-template-columns: minmax(0, 8fr) minmax(0, 5fr); align-items: start; }

.religion-card:has(details[open]) { grid-column: 1 / -1; }

.card {
  min-width: 0;
  padding: clamp(1rem, 2vw, 1.6rem);
  background: linear-gradient(145deg, var(--theme-wash), var(--surface) 52%);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card h3 { color: var(--theme-accent); font-size: clamp(1.07rem, 2vw, 1.28rem); letter-spacing: -.028em; }

.card-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: .65rem;
  margin-bottom: .85rem;
}

.card-heading p {
  margin-top: .4rem;
  color: var(--muted);
  font-size: .88rem;
}

.population-card {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 105% 3%, rgba(63, 188, 178, .28), transparent 57%),
    linear-gradient(143deg, #122b56 4%, #103e60 52%, #105950 100%);
  color: #fff;
  border-color: var(--navy);
}

.population-card h3 { color: #dfedf0; font-size: 1rem; letter-spacing: 0; font-weight: 620; }
.population-total { line-height: 1.12; margin: .6rem 0 .7rem; }

.population-total strong {
  font-size: clamp(2.8rem, 5.2vw, 4.5rem);
  font-weight: 720;
  letter-spacing: -.065em;
}

.population-total span { color: #dbe9ed; font-size: 1.02rem; margin-left: .2rem; }
.population-total, .sex-stats dd, .housing-stats dd, .bar-figure, .data-table, .age-side {
  font-variant-numeric: tabular-nums;
}

.population-change {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem .65rem;
  color: #dbe9ed;
  font-size: .83rem;
  margin-bottom: 1.1rem;
}

.population-change strong {
  display: inline-block;
  border-radius: 6px;
  background: #ffe3a5;
  color: #633b05;
  padding: .23rem .45rem;
  font-variant-numeric: tabular-nums;
}

.population-source-note {
  margin: 0 0 .8rem;
  color: #e0eef0;
  font-size: .8rem;
}

.population-breakdown {
  padding-top: 1rem;
  margin-top: auto;
  border-top: 1px solid rgba(214, 238, 246, .35);
}

.breakdown-label { color: #dfedf0; font-size: .85rem; font-weight: 620; }

.split-bar {
  display: flex;
  gap: 3px;
  height: 9px;
  overflow: hidden;
  margin-block: .65rem .9rem;
  border-radius: 5px;
}

.split-bar span { min-width: 0; background: var(--male-light); }
.split-bar span:last-child { background: var(--female-light); }

.sex-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.sex-stats dt { display: flex; align-items: center; gap: .42rem; color: #e0eef0; font-size: .84rem; }
.sex-stats dd { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 .44rem; }
.sex-stats strong { font-size: clamp(1.25rem, 2.45vw, 1.65rem); font-weight: 700; letter-spacing: -.035em; }
.sex-stats dd span { font-size: .8rem; color: #dbe9ed; }

.swatch { display: inline-block; width: .58rem; height: .58rem; border-radius: 2px; }
.swatch.male { background: var(--male-light); }
.swatch.female { background: var(--female-light); }

.trend-card {
  --trend-stroke: #087766;
  --trend-grid: #d5e8e2;
  --trend-fill-top: rgba(9, 136, 114, .23);
  --trend-fill-bottom: rgba(9, 136, 114, .035);
}

.trend-chart {
  position: relative;
  width: 100%;
  height: clamp(185px, 19vw, 232px);
  margin-top: .1rem;
}

.trend-card .table-details { margin-top: .35rem; }

.bar-list {
  display: grid;
  gap: .8rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.bar-text {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .3rem .75rem;
  font-size: .88rem;
}

.bar-label { color: var(--text); overflow-wrap: anywhere; }
.bar-figure { flex: none; font-weight: 700; }
.bar-figure small { color: var(--muted); font-weight: 500; margin-left: .3em; }

.bar-track { height: 6px; background: var(--theme-soft); margin-top: .3rem; border-radius: 4px; }
.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--bar-start), var(--bar-end));
}

.household-card { background: linear-gradient(145deg, var(--theme-soft), var(--theme-wash) 76%); }
.housing-stats { display: grid; gap: .9rem; }
.housing-stats div + div { padding-top: .85rem; border-top: 1px solid var(--theme-border); }
.housing-stats dt { font-size: .87rem; color: var(--muted); }
.housing-stats dd { color: var(--theme-accent); font-size: 1.85rem; font-weight: 700; letter-spacing: -.035em; }
.housing-stats small { font-size: .88rem; font-weight: 500; letter-spacing: normal; color: var(--muted); }

.age-grid { display: grid; gap: .44rem; font-size: .82rem; }

.age-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.3rem minmax(0, 1fr);
  gap: .3rem;
  align-items: center;
}

.age-header {
  margin-bottom: .15rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 660;
  text-align: center;
}

.age-label { text-align: center; color: var(--muted); white-space: nowrap; }
.age-side { display: flex; align-items: center; gap: .38rem; line-height: 1.2; }
.age-side.male { flex-direction: row-reverse; text-align: right; }
.age-track { display: flex; flex: 1; min-width: 0; height: 8px; }
.age-side.male .age-track { justify-content: flex-end; }
.age-side .bar-fill { border-radius: 2px; background: var(--female-fill); }
.age-side.male .bar-fill { background: var(--male-fill); }
.age-header span:first-child { color: #28539c; }
.age-header span:last-child { color: #096e5e; }
.age-count { min-width: 5ch; font-weight: 650; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  margin-bottom: .7rem;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  flex: 1 1 11rem;
  min-width: 0;
  max-width: 21rem;
  color: var(--text);
  font-size: .84rem;
  font-weight: 660;
}

.filters input, .filters select {
  width: 100%;
  min-height: 44px;
  padding: .55rem .7rem;
  border: 1px solid var(--theme-control);
  border-radius: 7px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
}

.filters input::placeholder { color: var(--muted); }
.table-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.note { color: var(--muted); font-size: .82rem; }
.results-label { margin-block: .7rem; }
.dataset-note:not(:empty) { margin-top: .85rem; }
.scroll-hint { display: none; margin: .4rem 0; }

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--theme-border);
  border-radius: 9px;
  scrollbar-color: var(--theme-control) var(--theme-wash);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  color: var(--text);
  font-size: .84rem;
  line-height: 1.4;
}

.data-table th, .data-table td {
  padding: .64rem .76rem;
  border-bottom: 1px solid var(--theme-border);
  text-align: left;
}

.data-table thead th {
  background: var(--theme-soft);
  color: var(--theme-accent);
  font-weight: 680;
}

.data-table tbody th { font-weight: 610; min-width: 7rem; }
.data-table tbody tr:nth-child(even) { background: var(--theme-wash); }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table .numeric { text-align: right; }
.data-table td.numeric { white-space: nowrap; }
.data-table .total-cell { color: var(--theme-accent); font-weight: 680; }
.sex-mobile { display: none; }
.place-district { display: block; color: var(--muted); font-size: .82em; font-weight: 480; margin-top: .1rem; }
#wilayah-tabel .data-table tbody th { min-width: 0; overflow-wrap: break-word; }

.table-details { margin-top: 1rem; }
.table-details[open] summary { margin-bottom: .4rem; }

.table-details summary, .methodology summary {
  min-height: 44px;
  padding: .67rem 0;
  color: var(--theme-accent);
  font-size: .86rem;
  font-weight: 660;
}

.pagination { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: .8rem; }

.pagination button {
  min-height: 44px;
  padding: .45rem .8rem;
  border: 1px solid var(--theme-control);
  border-radius: 7px;
  color: var(--theme-accent);
  background: var(--surface);
  font-size: .87rem;
  font-weight: 690;
}

.pagination button:not([disabled]):hover { background: var(--theme-soft); }
.pagination button:disabled { color: #5f7078; border-color: var(--line); background: #f4f7f7; }

.methodology {
  margin-top: 1.4rem;
  padding: 0 1.1rem .05rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
}

.methodology p { margin: 0 0 .65rem; color: var(--text); font-size: .88rem; max-width: 82ch; }
.source-links { display: flex; flex-wrap: wrap; gap: .15rem 1rem; list-style: none; padding: 0; margin: 0 0 .85rem; }
.source-links a { display: inline-flex; align-items: center; min-height: 44px; font-size: .85rem; }

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .84rem;
}

.footer-inner { min-height: 72px; padding-block: .7rem; flex-wrap: wrap; }
.site-footer a { display: inline-flex; align-items: center; gap: .25rem; min-height: 44px; font-weight: 660; }

@media (max-width: 950px) {
  .jobs-grid { grid-template-columns: 1fr; }
  .scroll-hint { display: block; }
}

@media (max-width: 790px) {
  .overview-grid, .overview-secondary, .profile-grid { grid-template-columns: 1fr; }
  .population-total strong { font-size: clamp(2.8rem, 9vw, 3.6rem); }
}

@media (max-width: 580px) {
  .wrap { width: calc(100% - 2rem); }
  .masthead { min-height: 61px; }
  .page-heading { flex-direction: column; align-items: start; gap: .95rem; padding-block: 1.4rem 1.15rem; }
  .page-heading h1 { text-wrap: initial; }
  .page-heading h1 + p { font-size: .91rem; }
  .edition { flex: 0 0 auto; width: min(100%, 19rem); padding-left: .75rem; }
  .topic-links { justify-content: space-between; gap: 0 .2rem; }
  .topic-links a { min-height: 48px; padding-inline: .12rem; font-size: .83rem; }
  .views { padding-top: 1rem; }
  .card-heading p, .bar-text { font-size: .83rem; }
  .age-row { grid-template-columns: minmax(0, 1fr) 3.5rem minmax(0, 1fr); }
  .age-grid { font-size: .76rem; }
  .age-side { gap: .24rem; }
  .data-table th, .data-table td { padding: .61rem .52rem; }
  .data-table-sex :is(th, td):is(:nth-child(2), :nth-child(3)) { display: none; }
  .sex-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: .14rem .62rem;
    margin-top: .2rem;
    color: var(--muted);
    font-size: .74rem;
    font-weight: 500;
  }
  .sex-mobile span { white-space: nowrap; }
  #wilayah-tabel .data-table { font-size: .79rem; }
  #wilayah-tabel .data-table thead th:first-child { width: 34%; }
  #wilayah-tabel .data-table th, #wilayah-tabel .data-table td { padding-inline: .4rem; }
  .footer-inner { gap: .2rem .5rem; }
}

@media (max-width: 355px) {
  .topic-links a { font-size: .76rem; }
  .sex-stats { gap: .5rem; }
  .population-change { font-size: .79rem; }
  #wilayah-tabel .data-table { font-size: .76rem; }
  #wilayah-tabel .data-table tbody th { overflow-wrap: anywhere; }
  #wilayah-tabel .data-table th, #wilayah-tabel .data-table td { padding-inline: .25rem; }
}
