:root {
  color-scheme: light;
  --ink: #12352a;
  --muted: #4d6b5e;
  --green: #09643e;
  --line: #d6e7dc;
  --paper: #f5faf6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 system-ui, Tahoma, sans-serif; }
a, button { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.site-header-inner, main { width: min(960px, calc(100% - 40px)); margin: 0 auto; }
.site-header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; gap: 9px; align-items: center; color: var(--ink); font-weight: 780; text-decoration: none; }
.button, .period button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; color: var(--green); font: inherit; font-weight: 680; white-space: nowrap; cursor: pointer; }
.button { padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; background: #fff; text-decoration: none; }
.button:disabled { cursor: wait; opacity: .55; }
.button:hover, .period button:hover { background: #eaf5ed; }
main { padding: 32px 0 44px; }
.intro h1 { margin: 0; font-size: clamp(2rem, 6.5vw, 3.25rem); line-height: 1.16; letter-spacing: -.02em; }
.intro p { margin: 8px 0 20px; color: var(--muted); }
.daily-card { border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.daily-card { padding: 19px 22px 12px; }

.stats-page .site-header-inner, .stats-page main { width: min(1080px, calc(100% - 48px)); }
.stats-page .site-header { background: #fbfefa; }
.stats-page .intro { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.stats-page .intro p { margin-bottom: 0; }
.stats-page .back { border-color: #bcdac8; background: #e8f5ec; }
.freshness {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 14px;
  min-height: 24px;
  margin: 11px 0 22px;
  color: var(--muted);
  font-size: .88rem;
}
#stats-status { margin: 0; font-weight: 720; }
#stats-status::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-inline-end: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  vertical-align: 1px;
}
#stats-status[data-state="fresh"] { color: var(--green); }
#stats-status[data-state="stale"] { color: #865a0f; }
#stats-status[data-state="error"] { color: #a13221; }
.totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.total {
  min-width: 0;
  padding: 15px 18px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.total-today { border-color: #bdddc9; background: #e7f5eb; }
.total p { margin: 0 0 6px; font-weight: 700; }
.total strong { font-size: clamp(1.9rem, 4.2vw, 2.8rem); line-height: 1.18; font-variant-numeric: tabular-nums; color: var(--green); }
.total .duration-value { display: block; font-size: clamp(1.35rem, 2.8vw, 1.95rem); line-height: 1.4; }
.total small { display: block; margin-top: 4px; color: var(--muted); }
.stats-page .daily-card { border-radius: 16px; }
.daily-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.daily-header h2 { margin: 0; font-size: clamp(1.18rem, 4.2vw, 1.5rem); }
.daily-header p { margin: 3px 0 0; color: var(--muted); font-size: .87rem; }
.period { display: flex; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: #f4f9f5; }
.period button { min-height: 44px; padding: 0 13px; border: 0; border-radius: 7px; background: transparent; }
.period button[aria-pressed="true"] { background: var(--green); color: #fff; }
.range-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 5px 12px;
  margin: 17px 0 10px;
  padding: 12px;
  border-top: 1px solid #d6e9dd;
  border-radius: 8px;
  background: #f1f8f3;
}
.range-summary p { margin: 0; }
.range-summary strong { color: var(--green); }
.range-total strong { margin-inline-start: 6px; font-size: 1.2rem; }
.empty-state { padding: 8px 0; color: var(--muted); }
.chart {
  --plot-height: 146px;
  display: grid;
  grid-template-columns: 37px minmax(0, 1fr);
  padding: 8px 0 0;
}
.chart-axis {
  height: var(--plot-height);
  display: grid;
  grid-template-rows: repeat(3, max-content);
  justify-items: end;
  align-content: space-between;
  padding-inline-end: 8px;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1;
}
.chart-bars {
  --days: 7;
  --chart-gap: 6px;
  display: grid;
  grid-template-columns: repeat(var(--days), minmax(0, 1fr));
  gap: var(--chart-gap);
  background: repeating-linear-gradient(to bottom, #edf4ee 0 1px, transparent 1px calc(var(--plot-height) / 2)) 0 0 / 100% var(--plot-height) no-repeat;
}
.chart-column { min-width: 0; text-align: center; }
.plot { height: var(--plot-height); display: flex; align-items: end; justify-content: center; border-bottom: 1px solid var(--line); }
.bar { width: min(100%, 42px); height: var(--height); border-radius: 4px 4px 0 0; background: #419a70; }
.bar.is-today { background: var(--green); }
.bar.is-missing { height: 4px; border-radius: 0; background: repeating-linear-gradient(135deg, #aac0b1 0 2px, #e6eee8 2px 4px); }
.chart-date { display: block; padding-top: 4px; white-space: nowrap; min-height: 20px; color: var(--muted); font-size: .72rem; }
.chart-key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 14px; padding: 0; list-style: none; color: var(--muted); font-size: .78rem; }
.key-swatch { display: inline-block; width: 10px; height: 10px; margin-inline-end: 4px; border-radius: 2px; }
.key-day { background: #419a70; }
.key-today { background: var(--green); }
.key-missing { background: repeating-linear-gradient(135deg, #aac0b1 0 2px, #e6eee8 2px 4px); }
.timing, .storage-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.timing { margin: 14px 0; }
.timing-stat, .storage-metrics > div { padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; }
.timing-stat p, .storage-metrics p { margin: 0 0 3px; font-weight: 650; }
.timing-stat strong, .storage-metrics strong { color: var(--green); font-size: 1.22rem; font-variant-numeric: tabular-nums; }
.timing-stat small, .storage-metrics small { display: block; color: var(--muted); }
.storage { margin-top: 18px; padding-bottom: 18px; }
.storage-metrics { margin-top: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#daily-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
#daily-table :is(th, td) { padding: 9px 10px; border-bottom: 1px solid var(--line); }
#daily-table thead th { background: #f4f9f5; color: var(--muted); font-size: .86rem; }
#daily-table th:first-child { text-align: left; }
#daily-table :is(th:not(:first-child), td) { text-align: right; }
#daily-table tbody tr:last-child > * { border-bottom: 0; }
.row-today { background: #eef8f0; }
.unrecorded td { color: var(--muted); }

@media (max-width: 790px) {
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 550px) {
  .site-header-inner, main { width: calc(100% - 24px); }
  main { padding-top: 23px; }
  .stats-page .site-header-inner, .stats-page main { width: calc(100% - 24px); }
  .stats-page .intro { align-items: flex-start; }
  .stats-page .intro p { font-size: .87rem; }
  #refresh { padding-inline: 8px; font-size: .82rem; }
  .freshness { font-size: .81rem; margin-bottom: 16px; }
  .totals { gap: 8px; }
  .total { padding: 12px 11px; font-size: .87rem; }
  .total small { min-height: 1rem; }
  .stats-page .daily-card { padding: 13px 10px 10px; }
  .period { width: 100%; }
  .period button { flex: 1; padding: 0 8px; }
  .range-summary { margin-top: 10px; font-size: .87rem; }
  .chart { --plot-height: 112px; grid-template-columns: 28px minmax(0, 1fr); }
  .chart-axis { padding-inline-end: 5px; }
  .chart-date { font-size: .68rem; text-align: left; }
  .chart-column:last-child .chart-date { text-align: right; }
  .timing, .storage-metrics { gap: 8px; font-size: .88rem; }
  #daily-table :is(th, td) { padding: 8px 6px; font-size: .85rem; }
}
@media (max-width: 345px) {
  .stats-page .intro { flex-wrap: wrap; }
  .storage-metrics { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .bar { transition: height .18s ease; }
}
