:root {
  color-scheme: light;
  --ink: #15372c;
  --muted: #64746d;
  --paper: #f2f0e8;
  --card: #fffdf7;
  --line: #d8d8cc;
  --green: #1f5a43;
  --acid: #d9ff5f;
  --orange: #ff7448;
  --blue: #cce7ff;
  --location: 290px;
  --slot: 54px;
  --court: 132px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
button, select, input[type="date"] { color: inherit; }

.masthead {
  min-height: 62px;
  padding: 12px clamp(16px, 3vw, 48px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid rgba(21, 55, 44, .22);
  background: var(--card);
}

.brand {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.03em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--acid);
}

.strapline, .live-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.live-note {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 9px;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22a463;
  box-shadow: 0 0 0 4px rgba(34, 164, 99, .14);
}

main {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 18px clamp(10px, 3vw, 48px) 72px;
}

.control-bar {
  position: sticky;
  z-index: 10;
  top: 8px;
  display: grid;
  grid-template-columns: auto minmax(190px, 1fr) minmax(145px, .65fr) auto auto;
  gap: 9px;
  padding: 9px;
  border: 1px solid rgba(21, 55, 44, .22);
  border-radius: 15px;
  background: rgba(255, 253, 247, .94);
  box-shadow: 0 14px 36px rgba(21, 55, 44, .08);
  backdrop-filter: blur(14px);
}

.date-control {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.control-bar label > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.date-control label, .select-control {
  min-width: 0;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}

.multi-select {
  position: relative;
  min-width: 190px;
}

.multi-select summary {
  height: 100%;
  min-height: 45px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px 32px 6px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  cursor: pointer;
  list-style: none;
}

.multi-select summary::-webkit-details-marker { display: none; }

.multi-select summary::after {
  content: "⌄";
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  transform: translateY(-50%);
}

.multi-select[open] summary {
  border-color: var(--ink);
}

.multi-select summary > span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.multi-select summary strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-options {
  position: absolute;
  z-index: 30;
  top: calc(100% + 7px);
  left: 0;
  width: min(340px, calc(100vw - 32px));
  max-height: min(520px, 70vh);
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(21, 55, 44, .28);
  border-radius: 11px;
  background: var(--card);
  box-shadow: 0 18px 42px rgba(21, 55, 44, .18);
}

.multi-select-options fieldset {
  margin: 0;
  padding: 7px 0 3px;
  border: 0;
  border-top: 1px solid var(--line);
}

.multi-select-options legend {
  padding: 0 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.multi-select-options label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.multi-select-options label:hover {
  background: var(--paper);
}

.multi-select-options input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--green);
}

.multi-select-all {
  margin-bottom: 6px;
  background: rgba(217, 255, 95, .24);
}

.date-control input, .select-control select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.icon-button, .refresh-button, .view-button {
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 800;
}

.icon-button {
  width: 34px;
  background: transparent;
}

.icon-button:hover { background: var(--paper); }

.refresh-button {
  padding: 0 19px;
  background: var(--acid);
}

.refresh-button:hover { filter: brightness(.95); }
.refresh-button:disabled { cursor: wait; opacity: .65; }

.view-toggle {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}

.view-button {
  min-width: 56px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.view-button.active {
  background: var(--ink);
  color: white;
}

.summary {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 38px;
  margin: 22px 4px 16px;
}

.summary div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.summary strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 31px;
  font-weight: 400;
}

.summary span, .summary p {
  color: var(--muted);
  font-size: 12px;
}

.summary p {
  justify-self: end;
  margin: 0;
  padding: 8px 13px;
  border-radius: 99px;
  background: var(--blue);
  color: var(--ink);
  font-weight: 700;
}

.notice {
  margin: 14px 0;
  padding: 13px 16px;
  border: 1px solid #e4b39e;
  border-radius: 11px;
  background: #fff0e8;
  font-size: 12px;
}

.notice[data-tone="success"] {
  border-color: #9dc8aa;
  background: #eaf8ed;
}

.import-dialog {
  width: min(620px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 28px 80px rgba(21, 55, 44, .32);
  color: var(--ink);
}

.import-dialog::backdrop {
  background: rgba(21, 55, 44, .55);
  backdrop-filter: blur(4px);
}

.import-dialog-card { padding: 24px; }

.import-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.import-dialog h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 400;
}

.dialog-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: 23px;
  line-height: 1;
}

.import-steps {
  margin: 22px 0;
  padding-left: 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.import-steps li + li { margin-top: 7px; }

.open-json-button {
  display: inline-block;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  text-decoration: none;
}

.open-json-button:hover { color: var(--acid); }

.json-input > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
}

.json-input textarea {
  width: 100%;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
}

.json-input textarea:focus {
  border-color: var(--ink);
  outline: 2px solid rgba(217, 255, 95, .8);
}

.import-status {
  min-height: 18px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.import-status[data-tone="error"] {
  color: #9b4a2f;
  font-weight: 700;
}

.import-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.cancel-button, .import-button {
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.cancel-button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.import-button {
  border: 0;
  background: var(--acid);
  color: var(--ink);
}

.availability { display: block; }

.continuous-card {
  scroll-margin-top: 100px;
  overflow: hidden;
  border: 1px solid rgba(21, 55, 44, .24);
  border-radius: 15px;
  background: var(--card);
}

.provider-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 7px;
  overflow: hidden;
  border: 1px solid rgba(21, 55, 44, .16);
  border-radius: 10px;
  background: white;
}

.provider-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.location-copy {
  min-width: 0;
}

.location-copy h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 400;
  letter-spacing: -.025em;
}

.booking-rule, .premium-rule, .pricing-rule {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.premium-rule {
  color: #9b4a2f;
  font-weight: 700;
}

.pricing-rule {
  color: var(--green);
  font-weight: 700;
}

.location-status {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.location-info[title] .location-status {
  color: #9b4a2f;
  cursor: help;
  font-weight: 700;
}

.inline-import-button {
  margin-left: 5px;
  padding: 3px 6px;
  border: 1px solid currentColor;
  border-radius: 5px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}

.inline-import-button:hover {
  background: var(--acid);
}

.venue-booking-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  text-underline-offset: 3px;
}

.provider-rules {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #f7f5ee;
}

.provider-rules-title {
  display: flex;
  width: 140px;
  flex: 0 0 140px;
  align-items: center;
  padding: 14px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.provider-rule {
  min-width: 230px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-left: 1px solid var(--line);
}

.provider-rule strong,
.provider-rule > div > span {
  display: block;
}

.provider-rule strong {
  margin-bottom: 2px;
  font-size: 11px;
}

.provider-rule > div > span {
  color: var(--muted);
  font-size: 10px;
}

.provider-rule .premium-rule {
  color: #9b4a2f;
  font-weight: 700;
}

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

.court-grid {
  display: grid;
  width: max-content;
  min-width: 100%;
}

.grid-cell {
  position: relative;
  min-height: 41px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}

.grid-cell::after {
  content: "";
  position: absolute;
  z-index: 9;
  inset: 0;
  pointer-events: none;
  transition: background-color .08s ease, box-shadow .08s ease;
}

.grid-cell.is-row-highlighted::after {
  background: rgba(204, 231, 255, .28);
  box-shadow: inset 0 2px 0 rgba(31, 90, 67, .38), inset 0 -2px 0 rgba(31, 90, 67, .38);
}

.grid-cell.is-column-highlighted::after {
  background: rgba(217, 255, 95, .18);
  box-shadow: inset 2px 0 0 rgba(31, 90, 67, .3), inset -2px 0 0 rgba(31, 90, 67, .3);
}

.grid-cell.is-row-highlighted.is-column-highlighted::after,
.grid-cell.is-hovered::after {
  background: rgba(255, 116, 72, .18);
  box-shadow: inset 0 0 0 3px var(--ink);
}

.grid-tooltip {
  position: fixed;
  z-index: 1000;
  width: max-content;
  max-width: min(300px, calc(100vw - 20px));
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(21, 55, 44, .3);
  border-radius: 9px;
  background: var(--ink);
  box-shadow: 0 10px 28px rgba(21, 55, 44, .24);
  color: white;
  pointer-events: none;
  font-size: 10px;
  line-height: 1.35;
}

.grid-tooltip[hidden] { display: none; }

.grid-tooltip strong {
  color: var(--acid);
  font-size: 12px;
}

.grid-tooltip span {
  color: rgba(255, 255, 255, .76);
}

.grid-tooltip .available {
  color: var(--acid);
  font-weight: 800;
}

.grid-tooltip .unavailable {
  color: #ffc0a9;
  font-weight: 800;
}

.grid-tooltip .hover-totals {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, .2);
  color: white;
  font-weight: 700;
}

.time-label {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 34px;
  background: #f7f5ee;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.location-corner,
.location-info {
  position: sticky;
  left: 0;
  z-index: 6;
  justify-items: start;
  padding-left: 14px;
  background: var(--card);
  box-shadow: 1px 0 0 var(--line);
}

.court-corner,
.court-name {
  position: sticky;
  left: var(--location);
  z-index: 5;
  justify-items: start;
  padding-left: 14px;
  background: var(--card);
  box-shadow: 1px 0 0 var(--line);
}

.location-corner,
.court-corner {
  z-index: 8;
  background: #f7f5ee;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.location-info {
  align-content: start;
  grid-template-columns: 42px minmax(0, 1fr);
  column-gap: 11px;
  padding: 13px 14px;
  border-right: 1px solid var(--line);
}

.court-name {
  line-height: 1.2;
  font-weight: 750;
}

.group-divider {
  border-top: 3px solid var(--ink);
}

.surface {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
}

.slot-cell { background: rgba(242, 240, 232, .34); }

.slot-link {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--acid);
  color: var(--ink);
  font-size: 0;
  text-decoration: none;
  transition: transform .12s ease, background .12s ease;
}

.slot-link::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.slot-link:hover, .slot-link:focus-visible {
  z-index: 1;
  background: var(--orange);
  outline: 0;
  box-shadow: inset 0 0 0 3px var(--ink);
}

.slot-link:hover::after { background: white; }

.slot-link.premium-slot {
  background: #ffe0d3;
}

.slot-link.premium-slot::after {
  background: #9b4a2f;
}

.empty-state, .loading-state {
  padding: 54px 24px;
  text-align: center;
  color: var(--muted);
}

.loading-state::before {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 13px;
  border: 3px solid var(--line);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.map-view {
  overflow: hidden;
  border: 1px solid rgba(21, 55, 44, .24);
  border-radius: 15px;
  background: #dde4dc;
}

.map-key {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 10px;
}

.key-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
}

.key-dot.open { background: var(--acid); border: 2px solid var(--ink); }
.key-dot.full { background: #b8beb5; }
.map {
  min-height: 600px;
  height: min(70vh, 760px);
  width: 100%;
}

.map-error {
  display: grid;
  min-height: 600px;
  place-items: center;
  padding: 30px;
  color: var(--muted);
}

.leaflet-container {
  background: #dce5dc;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.leaflet-control-zoom a {
  color: var(--ink);
}

.venue-marker-shell {
  background: transparent;
  border: 0;
}

.venue-marker {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50% 50% 50% 8px;
  box-shadow: 0 5px 14px rgba(21, 55, 44, .24);
  color: var(--ink);
  transform: rotate(-45deg);
}

.venue-marker.has-slots { background: var(--acid); }
.venue-marker.no-slots { background: #c7ccc4; }

.venue-marker strong {
  font-size: 9px;
  transform: rotate(45deg);
}

.venue-marker small {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid var(--card);
  border-radius: 99px;
  background: var(--orange);
  color: var(--ink);
  font-size: 8px;
  font-weight: 900;
  transform: rotate(45deg);
}

.venue-popup {
  min-width: 190px;
  display: grid;
  gap: 5px;
  color: var(--ink);
}

.venue-popup strong { font-size: 15px; }
.venue-popup span { color: var(--muted); font-size: 11px; }

.venue-popup button {
  margin-top: 5px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

@media (max-width: 900px) {
  :root { --location: 245px; --court: 124px; }
  .masthead { grid-template-columns: 1fr auto; }
  .strapline { display: none; }
  .control-bar { grid-template-columns: 1fr 1fr; }
  .multi-select { min-width: 0; }
  .date-control { min-width: 0; }
  .view-toggle, .refresh-button { min-height: 48px; }
  .summary { grid-template-columns: 1fr 1fr; gap: 14px; }
  .summary p { grid-column: 1 / -1; justify-self: start; }
  .provider-rules { overflow-x: auto; }
  .provider-rules-title { width: 120px; flex-basis: 120px; }
  .map { min-height: 500px; height: 65vh; }
}

@media (max-width: 580px) {
  .masthead { padding: 10px 14px; }
  .live-note { font-size: 10px; }
  main { padding: 9px 7px 48px; }
  .control-bar { top: 4px; grid-template-columns: 1fr; }
  .multi-select-options { width: 100%; }
  .date-control > label { flex: 1; }
  .view-button { min-height: 39px; }
  .import-dialog-card { padding: 18px; }
  .summary { margin: 17px 8px 12px; }
  .summary div { display: block; }
  .summary strong, .summary span { display: block; }
  :root { --location: 210px; --court: 112px; --slot: 47px; }
  .location-info {
    grid-template-columns: 1fr;
    row-gap: 8px;
    padding: 11px;
  }
  .provider-rules-title { display: none; }
  .provider-rule:first-of-type { border-left: 0; }
  .location-copy h2 { font-size: 17px; }
  .map-key { justify-content: flex-start; }
  .map { min-height: 460px; height: 68vh; }
}
