* { box-sizing: border-box; }

body {
  margin: 0;
  background: #eef3f6;
  color: #12334b;
  font: 1.125rem/1.4 system-ui, sans-serif;
}

main { max-width: 30rem; margin: auto; padding: 0.75rem; }
h1 { font-size: 1.7rem; margin: 0; }
h2 { font-size: 1.3rem; margin: 0 0 0.5rem; }
p { margin: 0.5rem 0; }
form, section { background: white; border-radius: 1rem; padding: 0.875rem; margin: 0.625rem 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.625rem; }
label, .field-label { display: block; font-weight: 650; font-size: 1rem; }
small { display: block; color: #415a6a; font-size: 0.875rem; font-weight: 400; }

input, output {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.375rem;
  margin-top: 0.25rem;
  border: 1px solid #617889;
  border-radius: 0.5rem;
  font: inherit;
  font-size: 1.5rem;
  color: #12334b;
  background: white;
}

.timestamp { min-width: 0; margin: 0 0 0.75rem; padding: 0; border: 0; }
.timestamp legend { padding: 0; margin-bottom: 0.25rem; }
.timestamp input { font-size: 1rem; }
.timestamp button { margin-top: 0.5rem; }
output { background: #eef3f6; overflow-wrap: anywhere; }
button {
  max-width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.625rem;
  background: #12334b;
  color: white;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button.secondary { background: #e6eef4; color: #12334b; }
button.full { width: 100%; margin-top: 0.5rem; }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 3px solid #145d9c; outline-offset: 3px; }
input[aria-invalid="true"] { border: 2px solid #a32121; }
article { border-top: 1px solid #cbd8e0; padding: 0.625rem 0; overflow-wrap: anywhere; }
article strong { font-size: 1.4rem; }
#estimate, [role="status"], footer { font-size: 0.9375rem; }
#storage-status { color: #802020; }
[role="status"]:empty { margin: 0; }
#history { margin-top: 0.5rem; }
main { overflow-wrap: anywhere; }

@media (max-width: 22em) {
  .timestamp .grid { grid-template-columns: minmax(0, 1fr); }
}


.page-nav { display: flex; gap: 0.5rem; margin: 0.5rem 0; flex-wrap: wrap; }
.page-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.375rem 0.875rem;
  border-radius: 0.5rem;
  background: #e1ebf2;
  color: #12334b;
  font-weight: 650;
}
.page-nav a[aria-current] { background: #12334b; color: white; text-decoration: none; }

.trends { max-width: 52rem; }
.trends select {
  width: 100%;
  max-width: 18rem;
  min-height: 44px;
  margin-top: 0.25rem;
  padding: 0.375rem;
  border: 1px solid #617889;
  border-radius: 0.5rem;
  color: inherit;
  background: white;
  font: inherit;
}
#trend-warning { color: #802020; }
#range-context, .trend-note { font-size: 0.9375rem; color: #415a6a; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.metric-grid > div { background: #eef3f6; border-radius: 0.5rem; padding: 0.5rem; }
.metric-grid dt { font-size: 0.9375rem; }
.metric-grid dd { margin: 0; font-weight: 700; }

.chart-panel { --primary: #135481; --secondary: #a13c26; --tertiary: #5e407c; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 1rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
}
.chart-legend li { display: flex; align-items: center; gap: 0.5rem; }
.legend-marker { width: 0.625rem; height: 0.625rem; flex: none; background: var(--series); }
.legend-marker.series-primary { border-radius: 50%; }
.legend-marker.series-tertiary { transform: rotate(45deg); }
.series-primary { --series: var(--primary); }
.series-secondary { --series: var(--secondary); }
.series-tertiary { --series: var(--tertiary); }
.chart-panel svg { width: 100%; height: auto; display: block; }
.chart-panel svg text { fill: #12334b; font: 12px system-ui, sans-serif; }
.chart-gridline { stroke: #cbd8e0; }
.chart-line { stroke: var(--series); stroke-width: 2; fill: none; }
.chart-line.series-secondary { stroke-dasharray: 6 4; }
.chart-line.series-tertiary { stroke-dasharray: 2 4; }
.chart-marker { fill: var(--series); }
.chart-marker.series-secondary, .chart-marker.series-tertiary { fill: none; stroke: var(--series); stroke-width: 1.5; }

.trends summary { min-height: 44px; padding: 0.5rem 0; font-weight: 650; cursor: pointer; }
.trends h3 { font-size: 1.0625rem; margin: 0.25rem 0; }
.daily-paging { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.5rem 0; }
.individual-readings { padding-left: 1.25rem; }
.individual-readings li + li { margin-top: 0.5rem; }

.app-status:not(:empty) { background: #e1ebf2; border-radius: 0.5rem; padding: 0.5rem 0.75rem; }
footer summary { display: list-item; min-height: 44px; padding: 0.5rem 0; cursor: pointer; font-weight: 650; }
