.calendar-product {
  display: grid;
  gap: 14px;
}

.calendar-topbar {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calendar-topbar h1 {
  font-size: 1.75rem;
}

.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 82%, var(--background));
}

.segmented-control button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 11px;
}

.segmented-control button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 6px 16px rgba(31, 37, 51, 0.10);
}

.calendar-filters {
  display: grid;
  grid-template-columns: 1.5fr 1.25fr 1fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.calendar-filters label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.calendar-filters label span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.calendar-stage {
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calendar-status {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 750;
}

.weekday-row,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, var(--background));
}

.weekday-row div {
  padding: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.month-grid {
  min-height: 620px;
}

.month-day {
  position: relative;
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 124px;
  padding: 9px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.month-day:nth-child(7n) {
  border-right: 0;
}

.month-day.outside {
  background: color-mix(in srgb, var(--surface) 72%, var(--background));
}

.month-day.today {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 42%, transparent);
}

.day-number {
  display: inline-flex;
  width: fit-content;
  min-width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-weight: 850;
}

.day-number:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.month-day.today .day-number {
  background: var(--primary);
  color: #ffffff;
}

.event-card {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 88%, var(--background));
  color: var(--text);
  padding: 7px 8px;
  text-align: left;
  font-size: 0.78rem;
  line-height: 1.22;
  box-shadow: 0 6px 14px rgba(31, 37, 51, 0.07);
}

.event-card strong,
.event-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-card.status-open {
  border-left-color: var(--primary);
}

.event-card.status-claimed {
  border-left-color: var(--success);
}

.event-card.status-completed {
  border-left-color: #8a94a6;
}

.event-card.status-cancelled {
  border-left-color: var(--danger);
}

.more-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 3px 0;
  text-align: left;
  font-weight: 850;
}

.calendar-empty {
  display: grid;
  place-items: center;
  min-height: 620px;
  color: var(--muted);
}

.week-view,
.day-view {
  display: grid;
  grid-template-columns: 70px 1fr;
  min-height: 680px;
}

.week-head {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 70px repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, var(--background));
}

.week-head div {
  padding: 12px 8px;
  text-align: center;
}

.week-head strong,
.week-head small {
  display: block;
}

.week-head small {
  color: var(--muted);
}

.time-gutter {
  display: grid;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 85%, var(--background));
}

.time-label {
  height: 68px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-width: 0;
}

.day-view .timeline-grid {
  grid-template-columns: 1fr;
}

.timeline-day {
  position: relative;
  min-height: 952px;
  border-right: 1px solid var(--border);
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 67px,
      var(--border) 68px
    );
}

.timeline-day:last-child {
  border-right: 0;
}

.time-slot {
  height: 34px;
  border: 0;
}

.time-slot:hover,
.time-slot.selecting {
  background: color-mix(in srgb, var(--primary) 11%, transparent);
}

.timeline-event {
  position: absolute;
  left: 6px;
  right: 6px;
  min-height: 36px;
  z-index: 2;
  overflow: hidden;
}

.timeline-event .event-card {
  height: 100%;
}

.day-view-header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, var(--background));
}

.day-view-header strong,
.day-view-header span {
  display: block;
}

.day-view-header span {
  color: var(--muted);
}

@media (max-width: 1060px) {
  .calendar-topbar {
    flex-direction: column;
  }

  .calendar-actions {
    justify-content: flex-start;
  }

  .calendar-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .calendar-topbar,
  .calendar-filters {
    padding: 12px;
  }

  .calendar-actions,
  .calendar-actions .button,
  .calendar-actions .segmented-control {
    width: 100%;
  }

  .calendar-actions {
    display: grid;
    grid-template-columns: 42px 1fr 42px;
  }

  .calendar-actions .segmented-control,
  .calendar-actions [data-open-create] {
    grid-column: 1 / -1;
  }

  .segmented-control {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-flow: row;
  }

  .calendar-filters {
    grid-template-columns: 1fr;
  }

  .weekday-row {
    display: none;
  }

  .month-grid {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .month-day {
    min-height: 112px;
    border-right: 0;
  }

  .month-day.outside {
    display: none;
  }

  .week-view,
  .day-view {
    grid-template-columns: 54px 1fr;
    overflow-x: auto;
  }

  .week-head {
    min-width: 760px;
  }

  .week-view .timeline-grid {
    min-width: 706px;
  }

  .time-gutter {
    min-width: 54px;
  }
}
