:root {
  --bg: #f7f5f0;
  --surface: #fafaf9;
  --ink: #1a1817;
  --muted-70: rgba(26, 24, 23, 0.7);
  --muted-50: rgba(26, 24, 23, 0.5);
  --muted-40: rgba(26, 24, 23, 0.4);
  --hairline: 1px solid rgba(26, 24, 23, 0.15);
  --grid: rgba(26, 24, 23, 0.1);
  --font: 'JetBrains Mono', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  border-radius: 0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--ink);
  transition: opacity 0.15s ease;
}

a:hover {
  opacity: 0.7;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  font-size: 13px;
  border-bottom: var(--hairline);
}

.header a {
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 32px 80px;
}

/* masthead */
.masthead {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 28px;
  border-bottom: var(--hairline);
}

.masthead__logo {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  flex: none;
  display: block;
}

.masthead__text {
  flex: 1;
  min-width: 0;
}

.masthead h1 {
  margin: 0;
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -1.5px;
}

.masthead__desc {
  margin: 4px 0 0;
  font-size: 14px;
  font-style: italic;
  color: var(--muted-70);
}

.btn-download {
  flex: none;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  padding: 13px 26px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-download:hover {
  opacity: 0.85;
}

/* kpis */
.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: rgba(26, 24, 23, 0.15);
  border: var(--hairline);
  border-top: none;
  margin-bottom: 32px;
}

.kpi {
  background: var(--surface);
  padding: 24px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi__label {
  font-size: 11px;
  color: var(--muted-50);
}

.kpi__value {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* cards */
.card {
  margin: 0 0 24px;
  padding: 22px 22px 18px;
  background: var(--surface);
  border: var(--hairline);
}

.card figcaption {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 14px;
}

.card__title {
  font-size: 14px;
  font-weight: 700;
}

.card__sub {
  font-size: 11.5px;
  color: var(--muted-50);
}

.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.card-row .card {
  margin-bottom: 24px;
}

/* controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 18px;
}

.opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted-50);
  cursor: pointer;
  user-select: none;
  margin-bottom: 12px;
}

.opt input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

/* legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 12px;
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted-70);
}

.legend__swatch {
  width: 10px;
  height: 10px;
  flex: none;
  border: 1px solid rgba(26, 24, 23, 0.25);
}

/* plots */
.plot {
  width: 100%;
  height: 320px;
}

.plot--short {
  height: 210px;
}

.plot svg {
  display: block;
  width: 100%;
  height: 100%;
}

.axis text {
  font-family: var(--font);
  font-size: 10px;
  fill: var(--muted-40);
}

.axis line {
  stroke: var(--grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.axis .axis__baseline {
  stroke: rgba(26, 24, 23, 0.28);
}

.crosshair {
  stroke: rgba(26, 24, 23, 0.45);
  stroke-width: 1;
  pointer-events: none;
  shape-rendering: crispEdges;
}

/* range + zoom bar */
.brush {
  margin-top: 10px;
  margin-left: 58px;
  margin-right: 6px;
  user-select: none;
}

/* the two short charts use a narrower y-axis gutter */
.card-row .brush {
  margin-left: 54px;
}

.brush__inner {
  width: 100%;
  height: 26px;
}

.brush__svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.brush__win {
  cursor: grab;
}

.brush__handle {
  cursor: ew-resize;
}

.brush__label {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--muted-40);
}

.brush__reset {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 10.5px;
  color: var(--muted-40);
  border-bottom: 1px solid rgba(26, 24, 23, 0.25);
  cursor: pointer;
  padding: 0;
}

.brush__reset[hidden] {
  visibility: hidden;
}

/* tooltip */
.tooltip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  background: var(--bg);
  border: 1px solid rgba(26, 24, 23, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.55;
  min-width: 190px;
}

.tooltip[hidden] {
  display: none;
}

.tooltip__day {
  font-weight: 700;
  margin-bottom: 6px;
  display: block;
}

.tooltip__row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.tooltip__row--total {
  border-top: 1px dashed rgba(26, 24, 23, 0.25);
  margin-top: 5px;
  padding-top: 5px;
  font-weight: 700;
}

.tooltip__sw {
  width: 9px;
  height: 9px;
  border: 1px solid rgba(26, 24, 23, 0.25);
}

.tooltip__name {
  color: var(--muted-70);
}

/* card footer: watermark left, table toggle right */
.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.wm {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  color: var(--muted-40);
  user-select: none;
}

.wm img {
  width: 17px;
  height: 17px;
  display: block;
  border-radius: 50%;
  opacity: 0.85;
}

/* table view */
.table-toggle {
  margin-top: 0;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 11px;
  color: var(--muted-50);
  border-bottom: 1px solid rgba(26, 24, 23, 0.3);
  cursor: pointer;
  padding: 0;
}

.table-host {
  margin-top: 14px;
  max-height: 300px;
  overflow: auto;
  border: var(--hairline);
}

.table-host[hidden] {
  display: none;
}

.table-host table {
  border-collapse: collapse;
  width: 100%;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.table-host th,
.table-host td {
  padding: 5px 9px;
  text-align: right;
  border-bottom: 1px solid rgba(26, 24, 23, 0.08);
  white-space: nowrap;
}

.table-host th:first-child,
.table-host td:first-child {
  text-align: left;
}

.table-host thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: var(--hairline);
  font-weight: 700;
}

.footnote {
  font-size: 11px;
  color: var(--muted-40);
  line-height: 1.7;
  margin: 4px 0 0;
}

.plot__empty {
  font-size: 12px;
  color: var(--muted-40);
  padding: 20px 0;
}

@media (max-width: 860px) {
  .card-row {
    grid-template-columns: 1fr;
  }

  .kpis {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .wrap {
    padding: 32px 20px 60px;
  }

  .header {
    padding: 16px 20px;
  }

  .masthead {
    flex-wrap: wrap;
    gap: 16px;
  }

  .kpi__value {
    font-size: 28px;
  }
}
