:root {
  --paper: #f7f6f1;
  --ink: #20352f;
  --muted: #64736b;
  --red: #b64430;
  --line: #d8ded4;
  --female: #b44c39;
  --male: #3c7764;
  --white: #fffefb;
  --green: #e7ece4;
  --serif: Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, select { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
a:hover, button.text-button:hover { text-decoration: underline; text-underline-offset: 5px; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid #b64430; outline-offset: 4px; }
button:hover { filter: brightness(0.95); }
[hidden] { display: none !important; }

h1, h2, h3, p { margin: 0; }
h2 { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.2; letter-spacing: -0.6px; }
h3 { font-size: 15px; }
p { line-height: 1.65; }
svg { display: block; width: 100%; }

.header {
  max-width: 1440px;
  margin: auto;
  min-height: 96px;
  padding: 0 5.6%;
  display: flex;
  align-items: center;
  gap: 36px;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-logo.small-logo {
  width: 28px;
  height: 28px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-copy small {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
}

.header nav {
  display: flex;
  align-items: stretch;
  gap: 26px;
  margin-left: 20px;
  height: 96px;
}

.nav-link {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  position: relative;
  gap: 6px;
  padding: 0;
  color: var(--muted);
  transition: color 0.15s;
}

.nav-link:hover { color: var(--ink); text-decoration: none; }
.nav-link.active { color: var(--ink); font-weight: 600; }
.nav-link.active:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--ink);
}

.nav-link.nav-home {
  font-weight: 500;
  color: var(--muted);
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  padding-right: 14px;
  margin-right: 4px;
}
.nav-link.nav-home:hover {
  color: var(--ink);
}

.edition {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 1.3px;
  white-space: nowrap;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #478c66;
  border-radius: 50%;
}

main {
  max-width: 1440px;
  padding: 0 5.6%;
  margin: auto;
}

.scope-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 24px;
  font-size: 10px;
  letter-spacing: 1.4px;
  font-weight: 600;
}

.scope-bar button { font-size: 11px; letter-spacing: 0; color: var(--muted); }
.muted { color: var(--muted); margin-left: 10px; font-weight: 400; }

.hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  min-height: 400px;
  padding: 44px 0 42px;
  gap: 46px;
  align-items: center;
}

.eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.7px;
  line-height: 1.4;
  color: #2b5545;
}

.hero .eyebrow {
  color: #2b5545;
  margin-bottom: 16px;
}

h1 {
  font-size: clamp(38px, 4.4vw, 62px);
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -2px;
  line-height: 1.06;
}

h1 span {
  font-style: italic;
  color: #4a6c58;
}

.hero-copy > p {
  color: var(--muted);
  font-size: 14px;
  max-width: 480px;
  margin-top: 18px;
  line-height: 1.75;
}

.switch-button {
  background: #25473b;
  color: #fff;
  padding: 14px 20px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  transition: background 0.15s, transform 0.15s;
}

.switch-button:hover {
  background: #173228;
  text-decoration: none;
  transform: translateY(-1px);
}

.switch-button span { font-size: 16px; }

.source-stamps {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 26px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.source-stamps .stamp-caption {
  font-size: 9px;
  font-weight: 400;
  color: var(--muted);
  border-left: 1px solid var(--line);
  padding-left: 16px;
  letter-spacing: 0;
}

.hero-chart-card {
  min-width: 0;
  align-self: stretch;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 22px 24px 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(32, 53, 47, 0.04);
}

.hero-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.card-eyebrow {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.card-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.2;
}

.hero-chart-toggles {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.toggle-btn {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 3px;
  color: var(--muted);
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.toggle-btn:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.03);
}

.toggle-btn.active {
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

.hero-chart-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: #f8f9f6;
  border: 1px solid #e2e7df;
  border-radius: 5px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.chart-metric {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.metric-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.female-metric .metric-label { color: var(--female); }
.male-metric .metric-label { color: var(--male); }

.metric-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 3px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.metric-val small {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.metric-diff {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 500;
}

.hero-svg-wrap {
  position: relative;
  width: 100%;
  min-height: 200px;
  border-radius: 4px;
  background: #fafbfa;
  border: 1px solid #edf0ec;
  overflow: hidden;
  user-select: none;
}

.hero-svg-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.milestones-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.milestone-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-right: 2px;
}

.milestone-tag {
  font-size: 10.5px;
  padding: 3px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  transition: all 0.15s;
}

.milestone-tag:hover {
  border-color: var(--ink);
  background: var(--white);
}

.milestone-tag.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.hero-chart-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--muted);
}

#hero-table-drawer {
  margin-top: 12px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--white);
}

#hero-table-drawer table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

#hero-table-drawer th, #hero-table-drawer td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

#hero-table-drawer th:first-child, #hero-table-drawer td:first-child {
  text-align: left;
}

.atlas-badge-strip {
  display: flex;
  justify-content: flex-end;
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--line);
}

.snapshot-label { font-size: 10px; color: var(--muted); }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin: 42px 0 24px;
  gap: 25px;
}

.section-heading .eyebrow { color: var(--muted); margin-bottom: 8px; }
.section-heading > p { font-size: 11px; color: var(--muted); text-align: right; }

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

.metric-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 24px 24px 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 9px;
  letter-spacing: 1.15px;
  line-height: 1.5;
  font-weight: 600;
}

.metric-top > span:first-child { display: flex; align-items: center; gap: 7px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.female { background: var(--female); }
.male { background: var(--male); }
.pill { padding: 3px 8px; background: #eef1ea; border-radius: 3px; font-size: 9px; letter-spacing: 0; font-weight: 600; }

.big-number {
  font-size: 58px;
  letter-spacing: -2px;
  margin: 22px 0 8px;
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.big-number small {
  font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  margin-left: 8px;
  color: var(--muted);
}

.metric-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.metric-card > p { font-size: 11px; color: var(--muted); margin-bottom: 16px; min-height: 36px; }
.metric-source {
  display: flex;
  justify-content: space-between;
  margin: auto -24px 0;
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  background: #fafbfa;
}

.population-card { background: #eef3eb; }

.panel { border: 1px solid var(--line); background: var(--white); border-radius: 4px; }
.explorer { margin-top: 26px; padding: 30px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.panel-heading .eyebrow { color: var(--muted); margin-bottom: 8px; }
.panel-heading h2 { font-size: 28px; }
.panel-heading p { font-size: 12px; color: var(--muted); margin-top: 6px; }

.select-label { font-size: 9px; letter-spacing: 0.6px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-weight: 600; }
select {
  font-size: 12px;
  padding: 8px 28px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  min-height: 38px;
}

.stage-controls { display: flex; gap: 10px; margin: 24px 0 28px; }
.stage-controls button {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 14px 18px;
  text-align: left;
  flex: 1;
  font-size: 16px;
  font-family: var(--serif);
  transition: all 0.2s;
  background: #fafbfa;
}

.stage-controls button > span {
  display: block;
  font-size: 8px;
  letter-spacing: 1px;
  font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 600;
}

.stage-controls button small {
  font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 10px;
  margin-left: 6px;
  color: var(--muted);
}

.stage-controls button.active { border-color: #3b6151; background: #ebf1ea; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.stage-controls button.active > span { color: var(--ink); }

.result-summary { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 14px; }
.result-summary h3 { font-size: 13px; font-weight: 500; }
.model-badge { font-size: 9px; background: #e8eee6; padding: 5px 9px; border-radius: 3px; color: #285443; font-weight: 500; }

.life-row { display: grid; grid-template-columns: 75px 1fr 160px; align-items: center; gap: 18px; margin: 20px 0; }
.life-sex { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.bar-track { height: 16px; background: #eef1ea; border-radius: 3px; display: flex; position: relative; }
.lived-bar { background: #cfd8cc; height: 100%; border-radius: 3px 0 0 3px; }
.remaining-bar { height: 100%; border-radius: 3px; }
.life-number { font-size: 22px; font-family: var(--serif); font-variant-numeric: tabular-nums; text-align: right; }
.life-number small { font-size: 10px; color: var(--muted); font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif; }
.life-number > span { display: block; font-size: 10px; color: var(--muted); font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif; margin-top: 4px; }
.bar-axis { margin: 0 178px 18px 93px; display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; position: relative; height: 12px; }
.bar-axis span { position: absolute; transform: translateX(-50%); }
.bar-legend { display: flex; gap: 18px; font-size: 9px; color: var(--muted); margin-left: 93px; }
.bar-legend i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; background: #cfd8cc; }
.explorer-foot { display: flex; justify-content: space-between; gap: 30px; align-items: center; border-top: 1px solid var(--line); margin-top: 24px; padding-top: 18px; }
.explorer-foot p { font-size: 10px; color: var(--muted); max-width: 720px; }
.text-button { font-size: 11px; padding: 4px 0; white-space: nowrap; color: #2b5545; font-weight: 600; }

.insights-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 24px; margin-top: 24px; }
.trend-panel { padding: 26px; }
.trend-panel .panel-heading h2 { font-size: 25px; }
.chart-legend { font-size: 10px; display: flex; gap: 14px; font-weight: 500; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.trend-svg { height: 210px; margin-top: 16px; overflow: visible; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 12px; }
.chart-foot p { font-size: 10px; color: var(--muted); }

table { border-collapse: collapse; width: 100%; font-size: 12px; margin-top: 18px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }

.reading-card {
  background: #eaf0e7;
  padding: 30px;
  display: flex;
  flex-direction: column;
  border-radius: 4px;
  border: 1px solid #d4dfd0;
}

.reading-card > .eyebrow { color: var(--muted); margin-bottom: 20px; }
.reading-card h2 { font-size: 32px; }
.reading-card p { font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.7; }
.reading-icons { font-size: 28px; color: #4e7865; margin: 20px 0; }
.reading-card .text-button { text-align: left; display: flex; justify-content: space-between; margin-top: auto; }

.source-banner {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 30px;
  margin: 44px 0 0;
  padding: 28px 0;
}

.source-banner .eyebrow { color: var(--muted); margin-bottom: 8px; }
.source-banner h2 { font-size: 25px; }
.source-banner p { color: var(--muted); font-size: 11px; margin-top: 6px; }

.outline-button {
  border: 1px solid #99aa99;
  border-radius: 3px;
  padding: 12px 18px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  gap: 16px;
  align-items: center;
  white-space: nowrap;
  background: var(--white);
  transition: all 0.15s;
}

.outline-button:hover { background: #ebf0e8; text-decoration: none; }
.data-notice { font-size: 11px; line-height: 1.7; color: var(--muted); margin: 15px 0; }

footer {
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 28px 5.6% 40px;
  max-width: 1440px;
  margin: auto;
}

.small-brand { font-size: 18px; }
footer p { font-size: 10px; color: var(--muted); }
footer > button { margin-left: auto; }

dialog {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  max-width: 720px;
  width: calc(100% - 32px);
  max-height: 85vh;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 25px 90px rgba(18, 45, 36, 0.2);
}

dialog::backdrop { background: rgba(20, 36, 30, 0.45); backdrop-filter: blur(3px); }
.dialog-heading {
  position: sticky;
  top: 0;
  background: var(--paper);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 26px;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}

.dialog-heading h2 { font-size: 24px; }
.dialog-heading button { width: 34px; height: 34px; font-size: 18px; }
#dialog-content { padding: 24px 26px; font-size: 13px; line-height: 1.7; }
#dialog-content h3 { margin: 20px 0 6px; font-size: 16px; }
#dialog-content p { margin-bottom: 12px; color: var(--muted); }
.source-entry { border-top: 1px solid var(--line); padding: 16px 0; }
.source-entry a { font-weight: 600; text-decoration: underline; text-underline-offset: 4px; color: var(--ink); }
.source-entry small { display: block; color: var(--muted); margin-top: 6px; font-size: 11px; }

.skip { position: absolute; left: 20px; top: -100px; padding: 12px; background: white; z-index: 5; }
.skip:focus { top: 12px; }
.error { color: #ac3b29 !important; background: #f9e4da; padding: 14px; border-radius: 3px; }

@media (min-width: 1440px) {
  .header, main, footer { padding-left: 80px; padding-right: 80px; }
}

@media (max-width: 1050px) {
  .header { gap: 20px; }
  .header nav { margin-left: 0; gap: 16px; }
  .edition { display: none; }
  .hero { gap: 24px; }
  h1 { font-size: 48px; }
  .big-number { font-size: 50px; }
  .insights-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .header {
    min-height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 14px 5% 10px;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(247, 248, 246, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .brand {
    font-size: 18px;
    justify-content: flex-start;
  }
  .brand-logo {
    width: 32px;
    height: 32px;
  }
  .brand-copy small {
    display: none;
  }
  .header nav {
    height: auto;
    margin-left: 0;
    gap: 8px;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 2px 6px;
    width: 100%;
  }
  .header nav::-webkit-scrollbar {
    display: none;
  }
  .nav-link {
    height: 34px;
    padding: 0 13px;
    background: #eef2ec;
    border: 1px solid #dce4dc;
    border-radius: 17px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    transition: all 0.15s ease;
  }
  .nav-link:after {
    display: none !important;
  }
  .nav-link:hover {
    color: var(--ink);
    background: #e4ebe2;
    text-decoration: none;
  }
  .nav-link.active {
    background: #17382d !important;
    color: #ffffff !important;
    border-color: #17382d !important;
    font-weight: 600;
  }
  .nav-link.nav-home {
    background: #e2ede5;
    border-color: #b7cebe;
    color: #1a4233;
    font-weight: 600;
  }
  .nav-link.nav-highlight {
    background: #f4efe7;
    border-color: #dfd5c4;
    color: #4a3e28;
  }
  .nav-link.nav-highlight .nav-tag {
    background: #5c4d32;
  }
  main { padding: 0 6%; }
  .scope-bar { font-size: 8px; padding-top: 18px; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding: 30px 0; }
  .hero h1 { font-size: 42px; }
  .hero-chart-card { padding: 18px 14px; }
  .hero-chart-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .hero-chart-toggles { align-self: flex-start; }
  .hero-chart-metrics { grid-template-columns: 1fr; gap: 8px; }
  .hero-svg-wrap {
    min-height: 220px;
    touch-action: pan-y;
  }
  .milestones-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 2px 8px;
    margin-top: 10px;
    width: 100%;
  }
  .milestones-bar::-webkit-scrollbar {
    display: none;
  }
  .milestone-label {
    flex-shrink: 0;
    font-size: 9px;
  }
  .milestone-tag {
    flex-shrink: 0;
    font-size: 11px;
    padding: 6px 11px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    border-radius: 16px;
    background: #ffffff;
  }
  .metrics-grid { grid-template-columns: 1fr; gap: 14px; }
  .stage-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 18px 0 20px;
  }
  .stage-controls button {
    min-width: 0;
    padding: 10px 6px;
    font-size: 13px;
    text-align: center;
  }
  .stage-controls button > span {
    font-size: 8px;
    margin-bottom: 3px;
    letter-spacing: 0.5px;
  }
  .stage-controls button small {
    display: block;
    margin-left: 0;
    margin-top: 2px;
    font-size: 9.5px;
  }
  .life-row {
    grid-template-columns: 55px 1fr 85px;
    gap: 8px;
    padding: 10px 0;
  }
  .life-sex {
    font-size: 11.5px;
  }
  .life-number {
    font-size: 14px;
    text-align: right;
  }
  .life-number small {
    font-size: 8.5px;
  }
  .bar-axis {
    margin: 4px 85px 14px 63px;
    height: 14px;
    font-size: 9.5px;
  }
  .bar-axis span:nth-child(2),
  .bar-axis span:nth-child(4),
  .bar-axis span:nth-child(6) {
    display: none; /* Hide intermediate ticks on mobile to avoid overlap */
  }
  .bar-legend {
    margin-left: 0;
    flex-direction: column;
    gap: 5px;
    font-size: 9.5px;
  }
  .trend-panel {
    padding: 20px 16px;
  }
  .trend-svg {
    height: 220px;
  }
  .trend-svg text {
    font-size: 11px !important;
  }

  /* Mobile Dialogs / Bottom Sheets */
  dialog {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    margin: auto auto 0 !important;
    border-radius: 18px 18px 0 0 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    padding-bottom: env(safe-area-inset-bottom, 20px) !important;
  }
  .dialog-heading {
    padding: 16px 20px;
    border-radius: 18px 18px 0 0;
  }
  .dialog-heading h2 {
    font-size: 20px;
  }
  .dialog-heading button {
    width: 36px;
    height: 36px;
    font-size: 20px;
    border-radius: 18px;
    background: #eef2ec;
  }
  #dialog-content {
    padding: 18px 20px;
    font-size: 13px;
  }
  footer { padding: 20px 6% 30px; flex-direction: column; align-items: flex-start; }
  footer > button { margin-left: 0; }

  /* Section Headings, Panel Headings, Source Banner Stacking */
  .panel-heading,
  .section-heading,
  .source-banner {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
  .panel-heading > div,
  .section-heading > div {
    width: 100%;
  }
  .panel-heading h2,
  .section-heading h2,
  .source-banner h2 {
    font-size: 27px !important;
    line-height: 1.18 !important;
  }
  .section-heading > p {
    text-align: left !important;
    font-size: 12px !important;
    margin-top: 0 !important;
  }
  .source-banner .outline-button {
    width: 100%;
    justify-content: center;
  }
  .scope-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 0;
  }

  /* View Switcher Tabs Mobile Optimization */
  .view-tabs-bar {
    width: 100%;
    margin: 12px 0 20px;
    padding-bottom: 12px;
  }
  .view-tab {
    flex: 1;
    justify-content: center;
    padding: 11px 10px;
    font-size: 13px;
    min-height: 44px;
    text-align: center;
  }
  .view-tab .tab-text-full {
    display: none !important;
  }
  .view-tab .tab-text-mobile {
    display: inline !important;
    font-weight: 600;
  }
}

/* ================================================= */
/* VIEW TABS & CONTRIBUTING FACTORS STYLING          */
/* ================================================= */

.view-tab .tab-text-mobile {
  display: none;
}

.view-tabs-bar {
  display: flex;
  justify-content: center;
  margin: 18px 0 28px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.site-tabs-wrap {
  display: flex;
  justify-content: center;
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid #d4ded6;
  padding: 10px 22px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s ease;
}

.view-tab:first-child {
  border-radius: 20px 0 0 20px;
  border-right: none;
}

.view-tab:last-child {
  border-radius: 0 20px 20px 0;
}

.view-tab:hover {
  color: var(--ink);
  background: #f4f7f4;
}

.view-tab.active {
  background: #17382d;
  color: #ffffff;
  border-color: #17382d;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(23, 56, 45, 0.15);
}

.tab-glyph {
  font-size: 11px;
}

.nav-tag {
  font-size: 9px;
  font-weight: 700;
  background: #2b5545;
  color: #ffffff;
  padding: 1px 6px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

.view-panel[hidden] {
  display: none !important;
}

/* Factors Hero */
.factors-hero {
  padding: 34px 0 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}

.factors-hero-copy {
  max-width: 860px;
}

.factors-hero h1 {
  font: 44px var(--serif);
  line-height: 1.12;
  margin: 10px 0 14px;
  color: var(--ink);
}

.factors-lead {
  font-size: 16px;
  line-height: 1.6;
  color: #3f4e46;
  margin-bottom: 18px;
}

.factors-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
}

.meta-pill {
  background: #eef3ef;
  border: 1px solid #dbe6dd;
  padding: 4px 10px;
  border-radius: 4px;
  color: #234336;
}

/* 3 Pillars Grid */
.pillars-overview {
  margin-bottom: 32px;
}

.pillars-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.pillar-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.pillar-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.pillar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.pillar-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #2b5545;
}

.pillar-weight-badge {
  font-size: 10px;
  font-weight: 600;
  background: #e7efe9;
  color: #1a4234;
  padding: 2px 7px;
  border-radius: 3px;
}

.pillar-icon {
  font-size: 28px;
  margin-bottom: 10px;
}

.pillar-card h3 {
  font: 22px var(--serif);
  color: var(--ink);
  margin-bottom: 8px;
}

.pillar-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.pillar-metrics-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  font-size: 11px;
  line-height: 1.55;
  color: #42524a;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pillar-metrics-list li {
  position: relative;
  padding-left: 12px;
}

.pillar-metrics-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #2b5545;
  font-weight: bold;
}

.pillar-source {
  margin-top: auto;
  font-size: 10px;
  color: var(--muted);
  border-top: 1px solid #edf2ee;
  padding-top: 10px;
}

/* Custom Score Tuner */
.score-tuner {
  margin-bottom: 32px;
  padding: 22px 24px;
}

.tuner-controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 18px;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.slider-val {
  font-family: var(--serif);
  font-size: 16px;
  color: #1a4234;
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: #2b5545;
  cursor: pointer;
}

/* Scoreboard */
.scoreboard-section {
  margin-bottom: 32px;
  padding: 24px 26px;
}

.scoreboard-filters {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.scoreboard-filters input[type="search"] {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  min-width: 260px;
}

.scoreboard-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  margin-top: 18px;
}

.scoreboard-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--white);
  max-height: 580px;
}

.scoreboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.scoreboard-table th {
  position: sticky;
  top: 0;
  background: #f4f7f4;
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}

.scoreboard-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #edf1ee;
  color: var(--ink);
  vertical-align: middle;
}

.scoreboard-table tr {
  cursor: pointer;
  transition: background 0.12s;
}

.scoreboard-table tr:hover {
  background: #f6faf7;
}

.scoreboard-table tr.active-row {
  background: #ebf5ee;
  font-weight: 600;
}

.th-rank, .td-rank { width: 44px; text-align: center; }
.rank-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.rank-badge.top-3 {
  color: #164e3b;
  font-weight: 800;
}

.entity-filter-tabs {
  display: inline-flex;
  background: #eef2ef;
  border-radius: 4px;
  padding: 2px;
  gap: 2px;
}

.entity-filter-btn {
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.entity-filter-btn:hover {
  color: var(--ink);
}

.entity-filter-btn.active {
  background: var(--white);
  color: #17382d;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.canton-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.canton-code-tag {
  font-size: 10px;
  font-weight: 700;
  background: #e4ebe5;
  color: #1e4537;
  padding: 1px 5px;
  border-radius: 3px;
}

.town-tag {
  font-size: 10px;
  font-weight: 700;
  background: #e1edf7;
  color: #1a568c;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.2px;
}

.score-num-big {
  font-size: 16px;
  font-family: var(--serif);
  font-weight: 600;
  color: #17382d;
}

.life-num-cell {
  font-family: var(--serif);
  font-size: 14px;
  color: #3b5045;
}

.pillar-mini-bars {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 140px;
}

.mini-bar-wrap {
  flex: 1;
  height: 6px;
  background: #eef2ee;
  border-radius: 3px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.mini-bar-fill.env { background: #38a169; }
.mini-bar-fill.ses { background: #3182ce; }
.mini-bar-fill.vitality { background: #d69e2e; }

/* Canton Deep Dive Inspector Card */
.canton-factor-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 580px;
  overflow-y: auto;
}

.factor-card-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 50px 16px;
  color: var(--muted);
}

.placeholder-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.factor-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.factor-card-header h3 {
  font: 24px var(--serif);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-hero-box {
  background: #f2f7f3;
  border: 1px solid #d5e3d7;
  border-radius: 4px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-hero-left {
  display: flex;
  flex-direction: column;
}

.score-hero-val {
  font-size: 36px;
  font-family: var(--serif);
  color: #17382d;
  line-height: 1;
  margin: 4px 0;
}

.score-hero-sub {
  font-size: 10px;
  color: var(--muted);
}

.card-breakdown-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.breakdown-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.breakdown-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.breakdown-row-label {
  font-weight: 600;
  color: var(--ink);
}

.breakdown-row-val {
  font-weight: 700;
  font-family: var(--serif);
}

.breakdown-progress-track {
  height: 8px;
  background: #edf1ee;
  border-radius: 4px;
  overflow: hidden;
}

.breakdown-progress-fill {
  height: 100%;
  border-radius: 4px;
}

.breakdown-row-sub {
  font-size: 10px;
  color: var(--muted);
}

.card-paradox-box {
  background: #fafbfa;
  border-left: 3px solid #2b5545;
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.5;
  color: #384c42;
}

/* Paradoxes Grid */
.paradoxes-section {
  margin-bottom: 32px;
  padding: 24px 26px;
}

.paradoxes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 14px;
}

.paradox-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
}

.paradox-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #2b5545;
  margin-bottom: 8px;
}

.paradox-card h3 {
  font: 18px var(--serif);
  color: var(--ink);
  margin-bottom: 8px;
}

.paradox-card p {
  font-size: 12px;
  line-height: 1.55;
  color: #475850;
  margin: 0;
}

@media (max-width: 950px) {
  .pillars-grid, .tuner-controls-grid, .paradoxes-grid {
    grid-template-columns: 1fr;
  }
  .scoreboard-layout {
    grid-template-columns: 1fr;
  }
}
