:root {
  --paper: #ebe7dc;
  --paper-deep: #d8d3c6;
  --ink: #292c28;
  --muted: #5f625b;
  --subdued: #7a7d75;
  color-scheme: light;
  font-family: "Helvetica LT Pro", "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: clamp(.65rem, 1.5vw, 1.25rem);
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

h1,
h2,
p {
  margin-top: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.simple-header__identity,
.live-state,
.metric__top,
.metric__reading,
.metric__trend,
.chart-scale,
.chart-x-axis,
.simple-footer,
.about-page__copy p,
.reset-dialog__panel > p {
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.simple-header,
.simple-main,
.simple-footer {
  width: 100%;
  max-width: 1800px;
  margin-inline: auto;
}

.simple-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: clamp(.65rem, 1.5vh, 1rem);
}

.simple-header__identity h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.25rem);
  font-weight: 500;
  letter-spacing: -.055em;
  line-height: .9;
}

.simple-header__identity > p:last-child {
  margin: .35rem 0 0;
  color: var(--muted);
  font-size: .85rem;
}

.simple-header__actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: .4rem;
}

.live-state {
  display: flex;
  min-height: 2.5rem;
  align-items: center;
  gap: .55rem;
  padding: .5rem .7rem;
  border: 2px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: .75rem;
  font-weight: 700;
}

.live-state__dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--subdued);
}

.is-live .live-state__dot {
  background: #16733b;
}

.simple-header__actions > button {
  display: inline-grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
}

.simple-header__actions > button:hover,
.simple-header__actions > button:focus-visible {
  color: var(--paper);
  background: var(--ink);
  box-shadow: 3px 3px 0 var(--subdued);
}

.simple-header__actions > button svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.simple-main {
  min-height: 0;
}

.metrics {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(.85rem, 1.5vw, 1.6rem);
  padding: .2rem clamp(.5rem, .8vw, .9rem) clamp(.75rem, 1.2vw, 1.25rem) .15rem;
  overflow: visible;
  background: var(--paper);
}

.metric {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: clamp(1rem, 2.2vw, 2rem);
  overflow: visible;
  border: 4px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--ink);
}

.metric:nth-child(1) {
  box-shadow: 8px 8px 0 var(--ink);
}

.metric:nth-child(2) {
  box-shadow: 9px 7px 0 var(--ink);
}

.metric:nth-child(3) {
  box-shadow: 7px 9px 0 var(--ink);
}

.metric__top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.condition-indicator {
  align-self: start;
  padding: .28rem .4rem .2rem;
  border: 2px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
  letter-spacing: .04em;
  line-height: 1;
  text-align: right;
}

.condition--green {
  --condition-color: #16733b;
}

.condition--orange {
  --condition-color: #d56a00;
}

.condition--red {
  --condition-color: #b5161b;
}

.metric[class*="condition--"] .condition-indicator {
  color: var(--paper);
  background: var(--condition-color);
}

.metric[class*="condition--"] .sparkline__line {
  stroke: var(--condition-color);
}

.metric[class*="condition--"] .sparkline__area {
  fill: var(--condition-color);
  opacity: .12;
}

.metric__reading {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin: clamp(1.5rem, 5vh, 4rem) 0 1rem;
  white-space: nowrap;
}

.metric__value {
  font-size: clamp(4rem, 8vw, 9rem);
  font-weight: 500;
  letter-spacing: -.085em;
  line-height: .78;
}

.metric__unit {
  font-size: .85rem;
  font-weight: 800;
}

.metric__trend {
  display: grid;
  gap: .15rem;
  margin-bottom: .55rem;
  font-variant-numeric: tabular-nums;
}

.metric__trend strong {
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.metric__trend small {
  color: var(--muted);
  font-size: .65rem;
  white-space: nowrap;
}

.metric__chart {
  display: grid;
  width: 100%;
  min-height: 8rem;
  flex: 1;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: .55rem;
  margin-top: auto;
  padding-top: 3.25rem;
}

.chart-scale {
  display: flex;
  min-width: 2.5rem;
  flex-direction: column;
  justify-content: space-between;
  grid-row: 1;
  padding-block: .1rem;
  font-size: .62rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
}

.chart-scale span::after {
  content: " —";
}

.sparkline {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: visible;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.chart-x-axis {
  display: flex;
  grid-column: 2;
  grid-row: 2;
  justify-content: space-between;
  padding-top: .25rem;
  color: var(--muted);
  font-size: .6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  line-height: 1;
}

.sparkline.is-inspecting {
  cursor: ew-resize;
}

.sparkline__line,
.sparkline__area,
.sparkline__crosshair,
.sparkline__point {
  vector-effect: non-scaling-stroke;
}

.sparkline__line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
}

.sparkline__area {
  fill: var(--ink);
  opacity: .06;
}

.sparkline__crosshair {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0;
}

.sparkline__point {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2;
  opacity: 0;
}

.sparkline.is-inspecting .sparkline__crosshair,
.sparkline.is-inspecting .sparkline__point {
  opacity: 1;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  display: grid;
  gap: .15rem;
  min-width: 8.5rem;
  padding: .55rem .65rem;
  border: 3px solid var(--ink);
  border-radius: 0;
  color: var(--paper);
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
  background: var(--ink);
  transform: translate(-50%, 0);
  transition:
    left 90ms cubic-bezier(.2, .8, .2, 1),
    opacity 90ms linear;
  will-change: left;
}

.chart-tooltip.is-visible {
  opacity: 1;
}

.metric.is-inspecting {
  z-index: 4;
}

.chart-tooltip strong {
  font-size: .9rem;
}

.chart-tooltip small {
  color: var(--paper-deep);
  font-size: .75rem;
  white-space: nowrap;
}

.simple-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: .55rem;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
}

dialog {
  color: var(--ink);
  background: var(--paper);
}

dialog::backdrop {
  background: rgba(41, 44, 40, .72);
}

.range-dialog,
.download-dialog,
.reset-dialog {
  width: min(40rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: auto;
  border: 4px solid var(--ink);
  border-radius: 0;
  box-shadow: 10px 10px 0 var(--ink);
}

.range-dialog form,
.download-dialog__panel,
.reset-dialog__panel {
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

.dialog-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 500;
  letter-spacing: -.045em;
}

.dialog-heading > button,
.about-page > header > button {
  width: 2.6rem;
  height: 2.6rem;
  flex: 0 0 auto;
  border: 3px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  background: var(--paper);
  font-size: 1.5rem;
}

.range-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .4rem;
  margin: 1.5rem 0 1rem;
}

.range-presets button,
.dialog-actions button {
  padding: .7rem;
  border: 3px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  background: var(--paper);
  font-size: .8rem;
  font-weight: 700;
}

.range-presets button:hover,
.range-presets button:focus-visible {
  color: var(--paper);
  background: var(--ink);
}

.range-fields,
.download-custom-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
}

.range-fields label,
.download-range,
.download-custom-range label {
  display: grid;
  gap: .35rem;
}

.range-fields span,
.download-range > span,
.download-custom-range span,
.download-dialog legend {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.range-fields input,
.download-range select,
.download-custom-range input {
  min-width: 0;
  min-height: 2.8rem;
  padding: .6rem;
  border: 3px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: 1rem;
}

.download-dialog fieldset {
  display: grid;
  gap: .5rem;
  margin: 1.25rem 0;
  padding: 0;
  border: 0;
}

.download-dialog legend {
  margin-bottom: .4rem;
}

.check-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .8rem;
  padding: .8rem;
  border: 3px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  background: var(--paper);
}

.check-option input {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--ink);
}

.check-option span {
  display: grid;
  gap: .1rem;
}

.check-option small {
  color: var(--muted);
}

.download-custom-range {
  margin-top: .75rem;
}

.download-custom-range[hidden] {
  display: none;
}

.download-error {
  min-height: 1.2rem;
  margin: .75rem 0;
  color: #8b1515;
  font-size: .85rem;
  font-weight: 700;
}

.dialog-actions {
  display: flex;
  justify-content: end;
  gap: .6rem;
}

.dialog-actions .primary {
  border-color: var(--ink);
  color: var(--paper);
  background: var(--ink);
}

.reset-link {
  padding: .7rem 0;
  border: 0;
  border-bottom: 2px solid currentColor;
  color: #8b1515;
  cursor: pointer;
  background: transparent;
  font-weight: 800;
}

.reset-dialog__panel > p {
  margin: 1.25rem 0;
  color: var(--muted);
  line-height: 1.55;
}

.reset-download {
  display: block;
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 3px solid var(--ink);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  font-weight: 800;
  box-shadow: 4px 4px 0 var(--ink);
}

.reset-download:hover,
.reset-download:focus-visible {
  color: var(--paper);
  background: var(--ink);
}

.reset-confirmation {
  display: grid;
  gap: .45rem;
  margin-top: .8rem;
}

.reset-confirmation > span {
  font-size: .85rem;
}

.reset-confirmation input {
  min-height: 3rem;
  padding: .65rem;
  border: 3px solid var(--ink);
  border-radius: 0;
  font-weight: 800;
}

.dialog-actions .danger {
  border-color: #8b1515;
  color: var(--paper);
  background: #8b1515;
}

.dialog-actions button:disabled {
  cursor: wait;
  opacity: .55;
}

.about-dialog {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
}

.about-page {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr);
  padding: clamp(1rem, 4vw, 4rem);
  background: var(--paper);
}

.about-page > header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.about-page > header h2 {
  max-width: 1000px;
  margin-bottom: 0;
  font-size: clamp(2.6rem, 7vw, 7rem);
  font-weight: 500;
  letter-spacing: -.06em;
  line-height: .92;
}

.about-page__body {
  display: grid;
  min-height: 0;
  grid-template-columns: 1.2fr .8fr;
  gap: clamp(2rem, 8vw, 8rem);
  align-items: center;
}

.about-page__copy {
  max-width: 760px;
}

.about-page__copy p {
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  line-height: 1.6;
}

.about-page__copy .about-page__lead {
  color: var(--ink);
  font-size: clamp(1.5rem, 3vw, 2.8rem);
  line-height: 1.18;
  letter-spacing: -.035em;
}

.brands {
  display: grid;
  gap: .65rem;
}

.brands a {
  display: grid;
  grid-template-columns: 3rem 1fr;
  align-items: center;
  gap: 1rem;
  padding: clamp(.8rem, 2vw, 1.4rem);
  border: 3px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  text-decoration: none;
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--ink);
}

.brands a:hover,
.brands a:focus-visible {
  color: var(--paper);
  background: var(--ink);
}

.brands img {
  width: 2.4rem;
  height: 2.4rem;
  object-fit: contain;
}

.brands span {
  display: grid;
  gap: .1rem;
}

.brands small {
  color: var(--muted);
}

.brands a:hover small,
.brands a:focus-visible small {
  color: var(--paper-deep);
}

@media (max-width: 700px) {
  body {
    padding: .55rem;
  }

  .simple-header {
    align-items: start;
    gap: .5rem;
    padding-bottom: .5rem;
  }

  .simple-header__identity .eyebrow {
    display: none;
  }

  .simple-header__identity h1 {
    font-size: 1.7rem;
  }

  .simple-header__identity > p:last-child {
    max-width: 10rem;
    overflow: hidden;
    font-size: .75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .simple-header__actions {
    gap: .3rem;
  }

  .live-state {
    position: absolute;
    right: .55rem;
    bottom: .45rem;
    min-height: 1.6rem;
    padding: .2rem .35rem;
    border: 0;
    font-size: .7rem;
  }

  .simple-header {
    position: relative;
    padding-bottom: 2.25rem;
  }

  .simple-header__actions > button {
    width: 2.35rem;
    height: 2.35rem;
  }

  .metrics {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: .55rem;
    padding: 0 .35rem .4rem 0;
  }

  .metric,
  .metric:nth-child(1),
  .metric:nth-child(2),
  .metric:nth-child(3) {
    margin: 0;
    box-shadow: 5px 5px 0 var(--ink);
  }

  .metric {
    display: grid;
    grid-template-columns: minmax(8rem, .65fr) 1.35fr;
    grid-template-rows: auto 1fr;
    padding: .7rem;
  }

  .metric__top,
  .metric__reading,
  .metric__trend {
    grid-column: 1;
  }

  .metric__trend {
    align-self: end;
    margin: 0;
  }

  .metric__trend small {
    font-size: .55rem;
  }

  .metric__top {
    font-size: .7rem;
  }

  .metric__top > span:last-child {
    max-width: 7.5rem;
    padding: .2rem .28rem .16rem;
    font-size: .55rem;
  }

  .metric__reading {
    align-self: end;
    margin: .4rem 0;
  }

  .metric__value {
    font-size: clamp(2.7rem, 14vw, 4.2rem);
  }

  .metric__unit {
    font-size: .8rem;
  }

  .metric__chart {
    grid-column: 2;
    grid-row: 1 / span 3;
    min-height: 3rem;
    padding-top: 2.9rem;
  }

  .chart-scale {
    min-width: 2rem;
    font-size: .55rem;
  }

  .simple-footer {
    padding-top: .35rem;
    font-size: .7rem;
  }

  .range-presets {
    grid-template-columns: 1fr 1fr;
  }

  .range-fields,
  .download-custom-range {
    grid-template-columns: 1fr;
  }

  .about-page__body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 1rem;
  }

  .about-page > header h2 {
    font-size: clamp(2rem, 10vw, 3.5rem);
  }

  .about-page__copy p {
    margin-bottom: .7rem;
    font-size: .9rem;
  }

  .about-page__copy .about-page__lead {
    font-size: 1.25rem;
  }

  .about-page .brands {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .about-page .brands a {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .about-page .brands small {
    display: none;
  }
}

@media (max-height: 650px) {
  .simple-header__identity > p:last-child,
  .simple-footer span:first-child {
    display: none;
  }

  .simple-header {
    padding-bottom: .45rem;
  }

  .metric__reading {
    margin: .35rem 0;
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 650px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body {
    display: block;
    padding: .45rem;
  }

  .simple-header {
    position: sticky;
    z-index: 5;
    top: 0;
    padding: .35rem 0 .55rem;
    background: var(--paper);
  }

  .simple-header__identity .eyebrow {
    display: none;
  }

  .simple-header__identity > p:last-child {
    display: block;
    margin-top: .2rem;
    font-size: .68rem;
  }

  .simple-header__identity h1 {
    font-size: 1.55rem;
  }

  .simple-header__actions > button {
    width: 2.2rem;
    height: 2.2rem;
  }

  .live-state {
    min-height: 2.2rem;
    padding: .35rem .55rem;
  }

  .metrics {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-rows: minmax(8.5rem, auto);
    gap: .45rem;
    padding: 0 .3rem .35rem 0;
  }

  .metric,
  .metric:nth-child(1),
  .metric:nth-child(2),
  .metric:nth-child(3) {
    display: grid;
    min-height: 8.5rem;
    grid-template-columns: minmax(9rem, .7fr) minmax(0, 1.3fr);
    grid-template-rows: auto 1fr auto;
    column-gap: .75rem;
    margin: 0;
    padding: .55rem .65rem;
    overflow: hidden;
    box-shadow: 4px 4px 0 var(--ink);
  }

  .metric__top,
  .metric__reading,
  .metric__trend {
    min-width: 0;
    grid-column: 1;
  }

  .metric__top {
    font-size: .62rem;
  }

  .metric__top > span:last-child {
    max-width: 7rem;
    padding: .18rem .25rem .14rem;
    font-size: .5rem;
  }

  .metric__reading {
    align-self: center;
    margin: .2rem 0;
  }

  .metric__value {
    font-size: clamp(2.25rem, 7vw, 3.5rem);
  }

  .metric__unit {
    font-size: .7rem;
  }

  .metric__trend {
    align-self: end;
    gap: 0;
    margin: 0;
  }

  .metric__trend strong {
    font-size: .58rem;
  }

  .metric__trend small {
    overflow: hidden;
    font-size: .5rem;
    text-overflow: ellipsis;
  }

  .metric__chart {
    width: auto;
    min-width: 0;
    min-height: 0;
    align-self: stretch;
    grid-column: 2;
    grid-row: 1 / -1;
    gap: .35rem;
    margin: 0;
    overflow: hidden;
    padding-top: 2.9rem;
  }

  .chart-scale {
    min-width: 1.8rem;
    font-size: .48rem;
  }

  .chart-x-axis {
    font-size: .48rem;
  }

  .sparkline {
    overflow: hidden;
  }

  .simple-footer {
    display: flex;
    padding: .35rem 0 .2rem;
    font-size: .62rem;
  }

  .simple-footer span:first-child {
    display: inline;
  }

}
