:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #172923;
  background: #eef3f1;
  font-size: 16px;
  --green: #075f46;
  --green-dark: #064936;
  --green-soft: #e7f2ee;
  --ink: #172923;
  --muted: #60716b;
  --line: #d9e3df;
  --paper: #ffffff;
  --program: #176b9d;
  --program-soft: #edf6fb;
  --reservation: #b64e2f;
  --reservation-soft: #fff2ed;
  --internal: #6e55a3;
  --internal-soft: #f4f1fa;
  --shadow: 0 12px 34px rgba(20, 54, 43, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #eef3f1;
}

body::before {
  content: "";
  display: block;
  height: 6px;
  background: var(--green);
}

body > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.4rem clamp(1rem, 4vw, 4rem);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 5px 24px rgba(20, 54, 43, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  min-width: 0;
}

.city-logo {
  display: block;
  width: clamp(4.25rem, 6vw, 5.5rem);
  height: auto;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.9rem, 4vw, 3.25rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.status {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}

button {
  min-height: 2.75rem;
  border: 1px solid #c8d5d0;
  border-radius: 0.75rem;
  padding: 0.65rem 0.95rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button:hover:not(:disabled) {
  border-color: #7ea697;
  background: #f7faf9;
  box-shadow: 0 5px 15px rgba(20, 54, 43, 0.08);
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid rgba(7, 95, 70, 0.25);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  background: #edf2f0;
  color: #71807b;
}

.view-toggle {
  display: flex;
  padding: 0.25rem;
  border: 1px solid #c8d5d0;
  border-radius: 0.9rem;
  background: #edf3f1;
}

.view-toggle button {
  min-height: 2.25rem;
  border: 0;
  border-radius: 0.62rem;
  padding: 0.45rem 0.85rem;
  background: transparent;
  box-shadow: none;
}

.view-toggle button:hover:not(:disabled) {
  border: 0;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: none;
  transform: none;
}

.view-toggle button[aria-pressed="true"] {
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 12px rgba(7, 95, 70, 0.2);
}

main {
  width: min(100%, 118rem);
  margin: 0 auto;
  padding: 1.35rem clamp(1rem, 4vw, 4rem) 3rem;
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.65rem 1.15rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.82);
  color: #4d625b;
  font-size: 0.86rem;
  box-shadow: 0 5px 18px rgba(20, 54, 43, 0.04);
}

.legend span {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
  background: #ccd8d4;
  box-shadow: 0 0 0 3px rgba(204, 216, 212, 0.28);
}

.dot.program { background: var(--program); box-shadow: 0 0 0 3px rgba(23, 107, 157, 0.12); }
.dot.reservation { background: var(--reservation); box-shadow: 0 0 0 3px rgba(182, 78, 47, 0.12); }
.dot.internal { background: var(--internal); box-shadow: 0 0 0 3px rgba(110, 85, 163, 0.12); }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(13rem, 1fr));
  gap: 0.8rem;
  overflow-x: auto;
  padding: 0.15rem 0.1rem 1rem;
  scroll-snap-type: x proximity;
  scrollbar-color: #9bb3aa transparent;
}

.calendar.day-view {
  grid-template-columns: minmax(20rem, 46rem);
  justify-content: center;
  overflow: visible;
}

.day {
  min-height: 24rem;
  overflow: hidden;
  scroll-snap-align: start;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.day.is-today {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(7, 95, 70, 0.12), var(--shadow);
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #f7faf9;
}

.day.is-today .day-header {
  background: var(--green);
  color: #fff;
}

.weekday {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.date {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.day.is-today .date { color: rgba(255, 255, 255, 0.8); }

.courts { padding: 0.9rem; }

.court {
  margin-bottom: 0.95rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid #e8eeeb;
}

.court:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.court h3 {
  margin: 0 0 0.48rem;
  color: #536861;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.event {
  margin: 0.42rem 0;
  padding: 0.62rem 0.68rem;
  border: 1px solid #d9e9f1;
  border-left: 4px solid var(--program);
  border-radius: 0.68rem;
  background: var(--program-soft);
}

.event.reservation {
  border-color: #f0d6cc;
  border-left-color: var(--reservation);
  background: var(--reservation-soft);
}

.event.internal {
  border-color: #e1d9f1;
  border-left-color: var(--internal);
  background: var(--internal-soft);
}

.time {
  display: block;
  margin-bottom: 0.22rem;
  color: #304a41;
  font-size: 0.76rem;
  font-weight: 800;
}

.title {
  display: block;
  font-size: 0.88rem;
  line-height: 1.35;
}

.empty {
  padding: 0.35rem 0;
  color: #8a9994;
  font-size: 0.83rem;
}

.error {
  padding: 2rem;
  border: 1px solid #e5b9ac;
  border-radius: 1rem;
  background: #fff7f4;
  color: #792f1d;
}

.note {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

#file-updated {
  margin-top: 0.15rem;
  font-weight: 650;
}

.loading { opacity: 0.55; }

@media (max-width: 920px) {
  body > header {
    align-items: flex-start;
    flex-direction: column;
    gap: 1.1rem;
  }

  .toolbar { justify-content: flex-start; }
}

@media (max-width: 760px) {
  body > header { padding: 1.15rem 1rem; }
  .brand { align-items: flex-start; gap: 0.85rem; }
  .city-logo { width: 4rem; }
  h1 { font-size: clamp(1.85rem, 9vw, 2.45rem); }
  .toolbar { width: 100%; }
  .view-toggle { width: 100%; }
  .view-toggle button { flex: 1; }
  #previous, #today, #next { flex: 1; padding-inline: 0.55rem; }
  main { padding: 1rem 0.75rem 2rem; }
  .legend { gap: 0.65rem 1rem; }
  .calendar, .calendar.day-view {
    grid-template-columns: 1fr;
    justify-content: stretch;
    overflow: visible;
    scroll-snap-type: none;
  }
  .day { min-height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
