:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --today: #2563eb;
  --excellent: #15803d;
  --good: #facc15;
  --bad: #ef4444;
  --tooltip-bg: #0f172a;
  --tooltip-ink: #f1f5f9;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

header h1 .muted {
  color: var(--muted);
  font-weight: 400;
}

header .lede {
  color: var(--muted);
  margin: 0.25rem 0 1.5rem;
  font-size: 0.9rem;
}

.status {
  color: var(--muted);
  text-align: center;
  padding: 4rem 0;
}

.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 0.75rem 1rem;
  border-radius: 0.25rem;
  font-size: 0.9rem;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.nav button {
  padding: 0.4rem 0.8rem;
  background: var(--panel);
  border: 1px solid #cbd5e1;
  border-radius: 0.25rem;
  cursor: pointer;
  font: inherit;
}

.nav button:hover:not(:disabled) { background: #f1f5f9; }
.nav button:disabled { opacity: 0.4; cursor: not-allowed; }

.nav .week-label { font-weight: 500; color: #334155; }

.grid-wrap { overflow-x: auto; }

.grid {
  display: inline-grid;
  grid-template-columns: 3rem repeat(7, minmax(5rem, 1fr));
  min-width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.25rem;
}

.grid .day-head,
.grid .hr-head,
.grid .cell,
.grid .empty {
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.grid .hr-head { border-left: none; }

.day-head {
  background: #f1f5f9;
  text-align: center;
  padding: 0.5rem 0;
}
.day-head .wd { font-size: 0.85rem; color: #334155; }
.day-head .date { font-size: 0.7rem; color: var(--muted); }
.day-head.today .wd,
.day-head.today .date { color: var(--today); font-weight: 600; }

.hr-head {
  background: #f8fafc;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.cell {
  position: relative;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: default;
}

.cell.excellent { background: var(--excellent); color: white; }
.cell.good      { background: var(--good); color: #0f172a; }
.cell.bad       { background: var(--bad); color: white; }

.empty { background: #f8fafc; height: 2.25rem; }

.tooltip {
  position: absolute;
  z-index: 50;
  left: 50%;
  transform: translateX(-50%);
  width: 11rem;
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  border-radius: 0.25rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.72rem;
  line-height: 1.5;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.cell[data-below="true"]  .tooltip { top: 100%; margin-top: 0.25rem; }
.cell[data-below="false"] .tooltip { bottom: 100%; margin-bottom: 0.25rem; }

.cell:hover { z-index: 10; }
.cell:hover .tooltip { opacity: 1; }

.tooltip .title { font-weight: 600; margin-bottom: 0.25rem; }
.tooltip .row   { color: #cbd5e1; }

.legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #334155;
}
.legend .swatch {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 0.2rem;
  margin-right: 0.4rem;
  vertical-align: text-bottom;
}
