:root {
  color-scheme: light;
  --background: #fbfaff;
  --foreground: #1c1a24;
  --muted: #5d5a6b;
  --card: #ffffff;
  --border: #e4e1ee;
  --radius: 10px;
  --header-h: 52px;
  --name-col: 214px;
  --need-col: 64px;
  --left-col: 62px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --c-junior: #7c3aed;
  --c-mid: #eab308;
  --c-senior: #0d9488;

  --c-rent: #2563eb;
  --c-everyday: #ea580c;
  --c-commute: #db2777;
  --c-health: #4d7c0f;
  --c-left: #16a34a;
  --c-short: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #16141d;
    --foreground: #ecebf2;
    --muted: #a6a3b5;
    --card: #1f1c28;
    --border: #322e3e;

    --c-junior: #a855f7;
    --c-mid: #facc15;
    --c-senior: #2dd4bf;

    --c-rent: #3b82f6;
    --c-everyday: #ea580c;
    --c-commute: #ec4899;
    --c-health: #65a30d;
    --c-left: #4ade80;
    --c-short: #f87171;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

html, body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font);
  font-size: 14px;
}

a { color: var(--c-junior); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: 16px;
  padding: 12px 16px 32px;
  align-items: start;
}

main { min-width: 0; }

.filters {
  position: sticky;
  top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 16px);
  max-height: calc(100dvh - var(--header-h) - 32px);
  overflow-y: auto;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.08);
  font-size: 13px;
}
.filters h2 { font-size: 15px; margin: 0 0 10px; }
.filters fieldset { border: 0; padding: 0; margin: 0 0 8px; }
.filters legend { font-weight: 700; padding: 0; margin-bottom: 6px; }
.filters label { display: flex; align-items: center; gap: 7px; padding: 1px 0; cursor: pointer; }
.filters input { width: 15px; height: 15px; margin: 0; accent-color: var(--c-junior); }
.filters .muted { color: var(--muted); font-size: 11.5px; margin: 0 0 6px; }
.filters label .muted { margin: 0 0 0 auto; }
.filters .quick { display: flex; gap: 6px; margin-bottom: 6px; }
.filters button {
  font: inherit;
  font-size: 12px;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
}
.filters button:hover { border-color: var(--muted); }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-inline: 12px; }
}

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 21px; margin: 48px 0 6px; scroll-margin-top: 64px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { line-height: 1.5; margin: 0 0 6px; }

.lead { font-size: 16px; color: var(--muted); max-width: 780px; }

header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  gap: 28px;
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 24px 0;
  background: var(--background);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--foreground);
  text-decoration: none;
  white-space: nowrap;
}
.tabs {
  display: flex;
  align-items: stretch;
  gap: 22px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs a {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--foreground); }
.tabs a[aria-current="true"] { color: var(--foreground); font-weight: 600; border-bottom-color: var(--foreground); }
.brand { gap: 9px; }
.brand img { display: block; width: 24px; height: 24px; border-radius: 6px; }

.chart-section { scroll-margin-top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 16px); }
.chart-section + .chart-section { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

.tab-sep { width: 1px; background: var(--border); margin: 14px 0; }


.warn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 18px 0 8px;
  font-size: 13px;
  line-height: 1.5;
}
.warn b { color: var(--c-junior); }

.scroll { overflow-x: auto; }
/* the last grid line and edge labels poke a pixel past the chart, which made the scroll box show a bar for nothing */
.chart { overflow-x: clip; }

.legend, .ctls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: center;
  font-size: 12px;
  margin: 6px 0 8px;
}
.legend span, .ctls label { display: inline-flex; align-items: center; gap: 6px; }
.ctls input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--c-junior); }
.ctls select {
  font: inherit;
  font-size: 12px;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
}
.key { width: 18px; height: 10px; border-radius: 0 5px 5px 0; display: inline-block; }
.key-line { width: 3px; height: 14px; border-radius: 1px; display: inline-block; background: var(--foreground); }

.axis { display: grid; font-size: 11px; height: 16px; }
.axis .ticks { position: relative; }
.axis .ticks span { position: absolute; transform: translateX(-50%); opacity: .7; white-space: nowrap; }
.target-handle {
  position: absolute;
  top: -24px;
  transform: translateX(-50%);
  z-index: 4;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--background);
  background: var(--foreground);
  border: 0;
  border-radius: 999px;
  padding: 2px 9px;
  cursor: ew-resize;
  touch-action: none;
}
.target-handle::before { content: "\2039  "; opacity: .6; }
.target-handle::after { content: "  \203A"; opacity: .6; }
.target-handle:focus-visible { outline: 2px solid var(--c-junior); outline-offset: 2px; }
body.dragging, body.dragging * { cursor: ew-resize !important; user-select: none; }

.tick-boxes { display: inline-flex; flex-wrap: wrap; gap: 6px 16px; }

.fold { margin-top: 6px; }
.fold > summary {
  position: relative;
  z-index: 3;
  cursor: pointer;
  padding: 8px 10px;
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.fold > summary:hover { color: var(--foreground); }

.empty { padding: 18px 0; color: var(--muted); }

.rows { position: relative; }
.rows .lines { position: absolute; top: 0; bottom: 0; right: 0; pointer-events: none; }
.rows .lines i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); opacity: .7; }
.rows .lines i.target {
  width: 2px;
  margin-left: -1px;
  background: var(--foreground);
  opacity: .9;
  z-index: 1;
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
}
.rows .lines i.target::before { content: ""; position: absolute; inset: 0 -5px; }

.row { display: grid; align-items: center; font-size: 12px; }
.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.cc { opacity: .65; margin-left: 4px; }
.track { position: relative; }
.bar { position: absolute; left: 0; border-radius: 0 8px 8px 0; }
.b-junior { background: var(--c-junior); }
.b-mid { background: var(--c-mid); }
.b-senior { background: var(--c-senior); }

.pay { position: absolute; width: 3px; margin-left: -1.5px; border-radius: 1px; box-shadow: 0 0 0 1px var(--background); }
.marker { position: absolute; width: 2px; margin-left: -1px; background: var(--foreground); border-radius: 1px; box-shadow: 0 0 0 2px var(--background); }

.lab[hidden] { display: none; }
.lab {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10.5px;
  line-height: 14px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 2;
  color: #fff;
  text-shadow: -1px 0 #1b1b1b, 1px 0 #1b1b1b, 0 -1px #1b1b1b, 0 1px #1b1b1b;
}
.lab.light { text-shadow: none; color: #fff; }
.lab.dark { text-shadow: none; color: #1b1b1b; }

.note { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

/* city accordions, used in every chart */
details.city > summary { list-style: none; cursor: pointer; }
details.city > summary::-webkit-details-marker { display: none; }
details.city > summary:hover .name { text-decoration: underline; }
details.city[open] > summary .name { font-weight: 700; }
#breakdown-chart details.city { border-bottom: 1px solid var(--border); }

.info {
  display: inline-grid;
  place-items: center;
  width: 11px;
  height: 11px;
  margin: -2px 6px 0 0;
  vertical-align: middle;
  border: 1px solid currentColor;
  border-radius: 50%;
  font: italic 700 7.5px/1 Georgia, "Times New Roman", serif;
  opacity: .5;
}
details.city > summary:hover .info { opacity: .9; }
details.city[open] .info { opacity: 1; background: var(--foreground); color: var(--background); border-color: var(--foreground); }

.left3 { display: grid; grid-template-columns: repeat(3, 1fr); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.left3 span { text-align: right; }
.left3 .short { color: var(--c-short); }
.left3.head { font-weight: 600; color: var(--muted); font-size: 11px; }
.stack { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 0 8px 8px 0; overflow: hidden; }
.seg { position: absolute; top: 0; bottom: 0; box-shadow: inset -2px 0 0 var(--background); }
.seg:last-child { box-shadow: none; }
.seg-rent { background: var(--c-rent); }
.seg-everyday { background: var(--c-everyday); }
.seg-commute { background: var(--c-commute); }
.seg-health { background: var(--c-health); }

.panel {
  position: relative;
  z-index: 3;
  background: var(--background);
  padding: 12px 4px 18px;
  display: grid;
  gap: 14px 28px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  font-size: 13px;
}
.panel table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.panel td, .panel th { padding: 3px 6px 3px 0; text-align: left; border-bottom: 1px solid var(--border); }
.panel th { font-weight: 600; color: var(--muted); font-size: 12px; }
.panel td.num, .panel th.num { text-align: right; }
.panel .wide { grid-column: 1 / -1; }
.panel ul { margin: 4px 0 0; padding-left: 18px; line-height: 1.5; }
.panel .sources a { margin-right: 10px; display: inline-block; }
.mini { display: grid; grid-template-columns: 110px 1fr 56px; gap: 4px 8px; align-items: center; }
.mini .mbar { height: 8px; border-radius: 0 4px 4px 0; background: var(--c-everyday); }
.mini .num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }

ul.method { line-height: 1.6; padding-left: 20px; }
footer { margin-top: 40px; font-size: 12px; color: var(--muted); }

/* hamburger menu, shown on phones only */
.menu-toggle {
  display: none;
  margin-left: auto;
  align-self: center;
  width: 40px;
  height: 40px;
  padding: 10px 9px;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: var(--foreground);
}
.menu-toggle span {
  display: block;
  height: 2px;
  margin: 4px 0;
  background: currentColor;
  border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
}
.menu-open .menu-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
.menu-open .menu-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 960px) {
  header.top { padding-inline: 16px; }

  .menu-toggle { display: block; }

  .tabs {
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 8px 0 14px;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 18px 40px rgb(0 0 0 / 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity .2s ease, transform .25s ease, visibility 0s linear .25s;
  }
  .menu-open .tabs {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity .2s ease, transform .25s ease;
  }
  .tabs a {
    padding: 14px 20px;
    font-size: 17px;
    border-bottom: 0;
    border-left: 3px solid transparent;
    margin: 0;
  }
  .tabs a[aria-current="true"] { border-left-color: var(--foreground); border-bottom-color: transparent; }
  .tab-sep { width: auto; height: 1px; margin: 6px 20px; }

}

@media (prefers-reduced-motion: reduce) {
  .menu-toggle span, .tabs { transition: none; }
}

/* phones: charts fit the screen instead of scrolling sideways */
@media (max-width: 600px) {
  :root { --name-col: 104px; --need-col: 40px; --left-col: 58px; }

  .layout { padding: 8px 10px 28px; gap: 10px; }
  header.top { padding-inline: 12px; }
  h1 { font-size: 19px; }

  .chart { min-width: 0; }
  .cc .code { display: none; }
  .name { padding-right: 4px; font-size: 11.5px; }
  .info { margin-right: 4px; }

  .legend, .ctls { gap: 4px 12px; }
  .ctls select { max-width: 100%; }
  .axis .ticks span { font-size: 9.5px; }
  .axis .ticks span:nth-child(even) { display: none; }
  .target-handle { font-size: 10px; padding: 2px 7px; }
  .left3 { font-size: 11px; }
  .left3.head { font-size: 9.5px; }

  .panel { grid-template-columns: minmax(0, 1fr); padding-inline: 0; }
  .panel table { font-size: 11.5px; display: block; overflow-x: auto; }
  .mini { grid-template-columns: 90px 1fr 50px; }
  .fold > summary { font-size: 11.5px; }
}

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.left3 { min-width: calc(var(--left-col) * var(--n, 3)); }

@media (max-width: 600px) {
  /* breakdown rows become: name and left-over on one line, then a full-width bar */
  #breakdown-chart .axis { grid-template-columns: 1fr auto !important; }
  #breakdown-chart .axis .ticks { display: none; }
  #breakdown-chart summary.row {
    grid-template-columns: 1fr auto !important;
    height: auto !important;
    row-gap: 3px;
    padding: 7px 0 6px;
  }
  #breakdown-chart summary .name { grid-column: 1; grid-row: 1; }
  #breakdown-chart summary .left3 { grid-column: 2; grid-row: 1; }
  #breakdown-chart summary .track { grid-column: 1 / -1; grid-row: 2; }
  #breakdown-chart .name { font-size: 12.5px; }
}

.current-section { display: none; }

@media (max-width: 960px) {
  .current-section {
    display: block;
    flex: 1;
    min-width: 0;
    align-self: center;
    text-align: right;
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .menu-toggle { margin-left: 0; }
}

@media (max-width: 600px) {
  /* salary rows match the breakdown rows: name and needed salary on one line, then a full-width bar */
  #salary-chart .axis { grid-template-columns: 1fr !important; }
  #salary-chart .axis > div:not(.ticks) { display: none; }
  #salary-chart summary.row {
    grid-template-columns: 1fr auto !important;
    height: auto !important;
    row-gap: 3px;
    padding: 7px 0 6px;
  }
  #salary-chart summary .name { grid-column: 1; grid-row: 1; font-size: 12.5px; }
  #salary-chart summary .track { grid-column: 1 / -1; grid-row: 2; }
  #salary-chart summary > div:last-child { grid-column: 2; grid-row: 1; }
  #salary-chart details.city { border-bottom: 1px solid var(--border); }
}

.neg-label {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--c-short);
  text-shadow: -1px 0 var(--background), 1px 0 var(--background), 0 -1px var(--background), 0 1px var(--background);
}

/* tablets: the filter stacks above the charts, so the charts get the full width and need no sideways scroll */
@media (max-width: 960px) {
  .chart { min-width: 0; }
}

/* a number that did not fit on its bar sits on a second line under it, with a dot in its level colour */
.lab.low {
  transform: none;
  padding-left: 9px;
  color: var(--foreground);
  text-shadow: none;
  font-size: 9px;
}
.lab.low::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--dot, var(--foreground));
}

.filters .cc-code { min-width: 1.6em; font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--muted); }

.stack.has-hot .seg:not(.hot) { opacity: .35; }
.seg.hot { z-index: 1; box-shadow: inset 0 0 0 2px var(--foreground); }

.tip {
  position: fixed;
  z-index: 60;
  max-width: 270px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--background);
  background: var(--foreground);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.3);
  pointer-events: none;
}
.tip[hidden] { display: none; }
.tip b { display: inline-flex; align-items: center; margin-right: 4px; }
.tip .dot { width: 9px; height: 9px; margin-right: 6px; }
.tip-sub { opacity: .75; font-size: 11px; margin-top: 2px; }
.tip ul { list-style: none; margin: 6px 0 0; padding: 6px 0 0; border-top: 1px solid color-mix(in srgb, var(--background) 30%, transparent); }
.tip li { display: flex; justify-content: space-between; gap: 14px; }
.tip li span { font-variant-numeric: tabular-nums; font-weight: 600; }

/* filter: a panel beside the charts on desktop; on phones a tab on the right edge opens it as a floating card */
.filter-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.filter-head h2 { margin: 0; }
.filter-head [data-summary], .filter-close, .filter-tab { display: none; }

.filter-tab,
.filter-close {
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}

@media (max-width: 960px) {
  .filters {
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 8px);
    right: 8px;
    bottom: 8px;
    width: min(330px, calc(100vw - 16px));
    max-height: none;
    z-index: 40;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 14px 44px rgb(0 0 0 / 0.38);
    transform: translateX(calc(100% + 16px));
    transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  }
  .filters.open { transform: none; }

  .filter-head [data-summary] {
    display: block;
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .filter-head h2 { flex: none; }

  .filters .filter-close {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: auto;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 8px;
  }
  .filters .filter-close:hover { color: var(--foreground); }

  .filter-tab {
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 12px);
    right: 0;
    z-index: 39;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    padding: 14px 0;
    background: color-mix(in srgb, var(--background) 72%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 10px 0 0 10px;
    transition: transform .26s cubic-bezier(.2, .8, .2, 1), color .15s ease;
  }
  .filter-tab:hover { color: var(--foreground); }
  .filter-tab.gone { transform: translateX(100%); }
  .filter-tab .filter-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c-short);
  }
  .filter-tab .filter-dot[hidden] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .filters, .filter-tab { transition: none; }
}

/* accordion: same colours as the charts */
.panel td .dot { margin-right: 7px; vertical-align: 1px; }
.panel .stackbar { display: flex; height: 10px; margin: 0 0 8px; border-radius: 5px; overflow: hidden; gap: 2px; }
.panel .stackbar i { display: block; min-width: 2px; }
.panel td.cost-name { white-space: nowrap; }
.panel .alt td { color: var(--muted); }
