:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e4e7ec;
  --line-soft: #eef0f3;
  --ink: #0f172a;
  --ink-2: #475467;
  --ink-3: #8a94a6;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }

/* header */
.hero { background: linear-gradient(180deg, #0b1220 0%, #111a2e 100%); color: #fff; padding: 36px 0 30px; }
.eyebrow { margin: 0 0 6px; font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: #93a4c3; font-weight: 600; }
.hero h1 { margin: 0; font-size: clamp(26px, 4vw, 38px); letter-spacing: -.02em; font-weight: 750; }
.lede { margin: 10px 0 0; color: #c4cee0; max-width: 820px; }
.lede b { color: #fff; font-weight: 650; }
.lede .line { display: block; }

/* sticky filter bar: three zones, each with its own look
   - Pay: a segmented switch on a grey track (pick exactly one), with its pay range next to it
   - Search: a filled text field
   - Filters: outlined pill buttons that open a list (combine as many as you like) */
.filterbar { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .94); backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); box-shadow: 0 2px 8px rgba(16, 24, 40, .04); }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-main { padding: 10px 0; flex-wrap: wrap; row-gap: 8px; }
.bar-filters { padding: 9px 0 10px; border-top: 1px solid var(--line-soft); align-items: flex-start; }
.zone { display: flex; align-items: center; gap: 10px; flex: 0 1 auto; min-width: 0; }
/* the pay filters sit in line with the pay switch and wrap, one button at a time, when the window is too narrow */
.zone-pay { flex-wrap: wrap; gap: 8px 5px; }
.zone-pay .seg.basis { margin-right: 5px; }
.filters.pay-filters { display: contents; }
.vdiv { width: 1px; height: 26px; background: var(--line); flex: none; margin: 0 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; min-width: 0; }
.search { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid transparent; border-radius: 10px;
  padding: 0 12px; height: 36px; flex: 1 1 240px; max-width: 640px; min-width: 220px; transition: background .15s, border-color .15s; }
.search:hover { border-color: var(--line); }
.search:focus-within { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 15px; height: 15px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; height: 100%; font-size: 14px; }
.fbtn { height: 32px; padding: 0 10px 0 11px; border: 1px solid var(--line); background: #fff; border-radius: 999px; cursor: pointer;
  font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.fbtn:hover { border-color: #b8c0cc; color: var(--ink); }
.fbtn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fbtn.on { background: var(--accent-soft); border-color: #b9cdfb; color: #1d4ed8; font-weight: 600; }
.fbtn .caret { width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); opacity: .55; }
.fbtn .badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; line-height: 17px; }
.fbtn[hidden] { display: none; }
.seg.basis { height: 36px; }
.seg.basis button { padding: 0 14px; font-size: 13.5px; white-space: nowrap; }
.seg.basis button .n { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-left: 6px; font-weight: 500; }
.clear-all { height: 32px; border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0 6px; }
.clear-all:hover { text-decoration: underline; }
.clear-all[hidden] { display: none; }

/* popover */
.pop { position: absolute; z-index: 40; background: #fff; border: 1px solid var(--line); border-radius: 12px; width: 320px;
  max-width: calc(100vw - 24px); box-shadow: 0 12px 32px rgba(16, 24, 40, .16); font-size: 13.5px; }
.pop-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line-soft); }
.pop-head b { display: block; font-size: 14px; }
.pop-head p { margin: 3px 0 0; color: var(--ink-3); font-size: 12.5px; }
.pop-list { max-height: min(52vh, 380px); overflow: auto; padding: 6px; }
.pop-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.pop-row:hover { background: var(--bg); }
.pop-row input { margin: 0; accent-color: var(--accent); }
.pop-row .lab { flex: 1; min-width: 0; }
.pop-row .n { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.pop-row .only { visibility: hidden; border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0 2px; }
.pop-row:hover .only { visibility: visible; }
.pop-row.zero .lab { color: var(--ink-3); }
.pop-row.zero .logo { opacity: .45; }
/* site logos, before the site's name */
.logo { width: 16px; height: 16px; flex: none; border-radius: 3px; object-fit: contain; vertical-align: -3px; }
.site { display: inline-flex; align-items: flex-start; gap: 6px; }
.site .logo { margin-top: 2px; }
.legend .item .logo { margin-right: -1px; }
.pop-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 14px 12px; border-top: 1px solid var(--line-soft); }
.linkbtn { white-space: nowrap; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; }
.linkbtn:hover { text-decoration: underline; }
.pop-body { padding: 12px 14px; display: grid; gap: 10px; }
.pop-body label { display: grid; gap: 4px; color: var(--ink-2); font-size: 12.5px; }
.pop-body input[type=number], .pop-body select, .pop-body input[type=search] { height: 34px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; background: #fff; font-size: 14px; color: var(--ink); }
.pop-body .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pop-body .check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); font-size: 13px; }
.pop-body .check input { margin-top: 3px; accent-color: var(--accent); }
.pop-body .hint { color: var(--ink-3); font-size: 12px; margin: 0; }

/* cards */
main { padding-top: 18px; padding-bottom: 40px; display: grid; gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.card h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.sub { margin: 4px 0 0; color: var(--ink-2); font-size: 13.5px; max-width: 720px; }
.sub b { color: var(--ink); font-weight: 650; }
.sub .also { color: var(--ink); }
.sub .linkbtn { font-size: inherit; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
/* wider than a phone: the controls stay in the top right corner; a longer title or text on the left takes more lines,
   and when room runs short the controls fold onto a second row, still on the right */
@media (min-width: 721px) {
  .card-head { flex-wrap: nowrap; align-items: flex-start; }
  .card-head > div:first-child { flex: 1 1 0; min-width: 260px; }
  .card-head .controls { flex: 0 1 auto; justify-content: flex-end; }
}
.ctl { display: grid; gap: 4px; font-size: 11.5px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.ctl select { height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 30px 0 10px; background: #fff; font-size: 14px;
  color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 500; cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #8a94a6 50%), linear-gradient(135deg, #8a94a6 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.ctl select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* "pick one" switches (pay, log/linear, legend mode): a grey track with the chosen option raised on it */
.seg { display: inline-flex; gap: 2px; padding: 3px; height: 34px; border-radius: 10px; background: #eceff3; box-shadow: inset 0 0 0 1px #e2e6ec; }
.seg button { border: 0; background: none; padding: 0 12px; border-radius: 7px; cursor: pointer; font-size: 14px; color: var(--ink-2);
  text-transform: none; letter-spacing: 0; font-weight: 500; display: inline-flex; align-items: center; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 650; box-shadow: 0 1px 2px rgba(16, 24, 40, .12), 0 0 0 1px rgba(16, 24, 40, .06); }
.seg button.on .n { color: var(--ink-2); }
.btn { height: 34px; padding: 0 14px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.btn:hover { border-color: #cdd3dc; }

/* chart */
.chart-wrap { position: relative; margin-top: 6px; }
.chart-scroll { overflow-x: auto; overflow-y: hidden; }
#chart { display: block; }
#chart text { font-family: inherit; }
.axis text { fill: var(--ink-2); font-size: 12px; }
.axis .domain { display: none; }
.grid line { stroke: var(--line-soft); }
.xlabel { cursor: pointer; }
.xlabel text { fill: var(--ink); font-size: 12.5px; }
.xlabel .n { fill: var(--ink-3); font-size: 11.5px; }
.xlabel:hover text.name { fill: var(--accent); text-decoration: underline; }
.ylab { fill: var(--ink-3); font-size: 12px; }
.empty { fill: var(--ink-3); font-size: 14px; }
.bar-total { fill: var(--ink-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ctl[hidden] { display: none; }
.tip { position: absolute; pointer-events: none; z-index: 10; background: #0f172a; color: #e5e9f0; border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; max-width: 320px; box-shadow: 0 10px 24px rgba(15, 23, 42, .25); line-height: 1.4; }
.tip b { color: #fff; display: block; font-size: 13.5px; margin-bottom: 2px; }
.tip .big { font-size: 18px; font-weight: 700; color: #fff; margin: 4px 0 2px; }
.tip .muted { color: #9aa6b8; }
.tip .sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.tip table { border-collapse: collapse; margin-top: 4px; }
.tip td { padding: 1px 10px 1px 0; }
.tip td + td { text-align: right; font-variant-numeric: tabular-nums; color: #fff; }
.legend { margin-top: 10px; font-size: 13px; }
.legend:empty { display: none; }
.legend-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 6px; }
.legend .mode { color: var(--ink-3); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.seg.mini { height: 28px; padding: 2px; border-radius: 8px; }
.seg.mini button { font-size: 12.5px; padding: 0 9px; border-radius: 6px; }
.legend-items { display: flex; flex-wrap: wrap; gap: 2px 6px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: 1px solid transparent; background: none;
  padding: 2px 8px 2px 6px; border-radius: 999px; color: var(--ink-2); transition: opacity .15s, background .15s; }
.legend .item:hover { color: var(--ink); background: var(--bg); }
.legend .item.off { opacity: .45; text-decoration: line-through; }
.legend .item.dim { opacity: .5; }
.legend .item.lit { background: #fff; border-color: var(--ink); color: var(--ink); font-weight: 600; }
.legend .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend .item.lit .sw { box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--ink); }
.legend .n { color: var(--ink-3); font-variant-numeric: tabular-nums; font-weight: 400; }
.legend .note-grey { align-self: center; font-size: 12px; padding-left: 4px; }
.legend .ttl { color: var(--ink-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.note { margin: 10px 0 0; color: var(--ink-3); font-size: 12.5px; }

/* table */
.table-scroll { overflow-x: auto; margin: 4px -20px 0; }
#table { border-collapse: collapse; width: 100%; font-size: 13.5px; min-width: 1060px; }
#table th, #table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
#table th:first-child, #table td:first-child { padding-left: 20px; }
#table th:last-child, #table td:last-child { padding-right: 20px; }
#table thead th { background: #fafbfc; color: var(--ink-2); font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .03em; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
#table thead th:hover { color: var(--ink); }
#table thead th .arr { color: var(--accent); margin-left: 3px; }
#table th.num, #table td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.job { cursor: pointer; }
tbody tr.job:hover { background: #fafbfd; }
tbody tr.job.sel { background: #eef4ff; box-shadow: inset 3px 0 0 var(--accent); }
tbody tr.job.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: #fde68a; } 100% { background: #eef4ff; } }
.t-title { font-weight: 600; color: var(--ink); }
.t-sub { color: var(--ink-3); font-size: 12.5px; margin-top: 1px; }
.hr { font-weight: 700; }
.muted { color: var(--ink-3); }
.tag { display: inline-block; white-space: nowrap; font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--line-soft); color: var(--ink-2); margin-top: 3px; }
.tag.warn { background: #fff4e0; color: #9a5b00; }
#table td.nowrap { white-space: nowrap; }
tr.detail td { background: #fbfcfe; padding-top: 4px; padding-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 24px; }
.detail-grid div { font-size: 13px; }
.detail-grid dt { color: var(--ink-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.detail-grid dd { margin: 2px 0 0; color: var(--ink); overflow-wrap: anywhere; }
.detail-top { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 4px 0 12px; }
.detail-top .btn { display: inline-flex; align-items: center; background: var(--ink); color: #fff; border-color: var(--ink); }
.detail-top .btn:hover { text-decoration: none; background: #1e293b; }
.more { display: flex; gap: 10px; justify-content: center; padding-top: 14px; color: var(--ink-3); font-size: 13px; align-items: center; flex-wrap: wrap; }
.more:empty { display: none; }

/* about */
.about ul { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); display: grid; gap: 6px; max-width: 920px; }
.about b { color: var(--ink); }
.about .sub { margin: 14px 0 0; color: var(--ink-2); }
.about .muted { color: var(--ink-3); }
.foot { color: var(--ink-3); font-size: 12.5px; margin: 14px 0 0; }

/* the search box goes on its own line, without the divider, when the pay controls leave it too little room
   (app.js sets .stacked from the buttons' own widths, so the layout cannot flip back and forth) */
.bar-main.stacked .vdiv { display: none; }
.bar-main.stacked .search { flex-basis: 100%; }

@media (max-width: 720px) {
  .wrap { padding: 0 12px; }
  .card { padding: 14px 12px; border-radius: 12px; }
  .table-scroll { margin: 4px -12px 0; }
  #table th:first-child, #table td:first-child { padding-left: 12px; }
  /* phone: pay switch, then search, then one sideways-scrolling row of filters */
  .bar-main { flex-wrap: wrap; gap: 8px; padding: 8px 0; }
  .zone-pay { width: 100%; }
  .filters.pay-filters { display: none; }
  .vdiv { display: none; }
  .seg.basis { flex: 1; height: 34px; }
  .seg.basis button { flex: 1; justify-content: center; padding: 0 6px; font-size: 13px; }
  .seg.basis button .n { display: none; }
  .search { flex: 1 1 100%; max-width: none; height: 34px; }
  .bar-filters { padding: 8px 0; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .filters::-webkit-scrollbar { display: none; }
  .fbtn { flex: none; }
  .controls { width: 100%; }
  .ctl { flex: 1 1 140px; }
  .ctl select { width: 100%; }
}
